Open ProfessorAmanda opened 2 years ago
Progress update – I tried to come up with a very basic layout based on my understanding of the concept. Please let me know if you think it's the right direction!
Imagined user experience:
Hi Professors,
More progress update – I built a very basic prototype in the branch measurementError
. It would be very helpful if I can look at the Stata code before moving forward so that I can verify I'm on the right direction.
Please let me know if there's issue accessing the branch, or if you would like a zoom call so I can demo it and we can talk about it. Thanks!!
Best, Wayne
clear all set seed 8675308 set obs 10
gen point=_n gen x=_n gen error=runiform(-1,1)100 gen error=runiform()*100
gen y=2-20*x+error
gen meas_error=runiform()30 gen sign=runiform(-1,1) gen mis_x=x+meas_errorsign
scatter y x, mlabel(point) mcolor(green) name(orig, replace) xscale(range(-10 30)) xlabel(-10(20)30) legend(off)
scatter y mis_x, mlabel(point) mcolor(orange) name(mis, replace) xscale(range(-10 30)) xlabel(-10(20)30) legend(off)
twoway (scatter y x , mlabel(point) mcolor(green)) (lfit y x ), name(orig_line, replace) xscale(range(-10 30)) legend(off)
twoway (scatter y mis_x , mlabel(point) mcolor(orange)) (lfit y mis_x), name(mis_line, replace) xscale(range(-10 30)) legend(off)
twoway (scatter y x , mlabel(point) mcolor(green)) (scatter y mis_x, mlabel(point) mcolor(orange)), name(both, replace) xscale(range(-10 30)) legend(off)
twoway (scatter y x , mlabel(point) mcolor(green)) (lfit y x) (scatter y mis_x, mlabel(point) mcolor(orange)) (lfit y mis_x), name(both_line, replace) xscale(range(-10 30)) legend(off)
reg y x
reg y mis_x
Looks like we are getting close to a deployable version already! This still needs:
Thanks for the comments! I've added the display of regression line equations which show / hide in sync with the lines in the chart. However, I'm a bit unsure about the term / notation that should be used here. Is f(x)
okay in this context?
Hi Professor Byker,
Based on our discussion yesterday, I was able to produce a prototype for the second part of Measurement Error. It can be accessed from branch measurementError
.
However, I discovered that when I set the parameters to 1000 data points with error in the X-direction, randomly selecting 100 points per sample(iteration), and conducting about 100 iterations, the regression lines from each iteration are marked as the grey ones and their slopes do not seem to lean towards 0, which is not what we expected. Am I making some apparent mistake here? We can quickly run through it after tomorrow's meeting if it works for you. Thanks a lot!
Best, Wayne
Hi Wayne, As an initial test, can you start with an "original data regression" that has a strongly positive (or negative slope)? Like generate a dataset with a slope of +1 or even +2, then produce the error data from that, and sample. Does that make sense?
Tanya
Tanya Byker
Associate Professor, Economics
Middlebury College @.**@.>
From: Wayne Wang @.> Sent: Thursday, June 16, 2022 5:15 PM To: ProfessorAmanda/econsimulations @.> Cc: Byker, Tanya S. @.>; Assign @.> Subject: Re: [ProfessorAmanda/econsimulations] New Module: Measurement Error (Issue #282)
Hi Professor Byker,
Based on our discussion yesterday, I was able to produce a prototype for the second part of Measurement Error. It can be accessed from branch measurementError.
However, I discovered that when I set the parameters to 1000 data points with error in the X-direction, randomly selecting 100 points per sample(iteration), and conducting about 100 iterations, the regression lines from each iteration are marked as the grey ones and their slopes do not seem to lean towards 0, which is not what we expected. Am I making some apparent mistake here? We can quickly run through it after tomorrow's meeting if it works for you. Thanks a lot!
Best, Wayne
— Reply to this email directly, view it on GitHubhttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FProfessorAmanda%2Feconsimulations%2Fissues%2F282%23issuecomment-1158137065&data=05%7C01%7Ctbyker%40middlebury.edu%7C225d2ae2b96e4e173fea08da4fdd6198%7Ca1bb0a191576421dbe93b3a7d4b6dcaa%7C1%7C0%7C637910109494569000%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=8TNYkwmVNZtbowp8SrY%2B5CDcB50EcavM1TxPgEzIcY8%3D&reserved=0, or unsubscribehttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAP65VZ6IXRN2AUT76V5MTZLVPOKQFANCNFSM5X7RR4KQ&data=05%7C01%7Ctbyker%40middlebury.edu%7C225d2ae2b96e4e173fea08da4fdd6198%7Ca1bb0a191576421dbe93b3a7d4b6dcaa%7C1%7C0%7C637910109494569000%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Bqo3EvDSM8t%2Fanc2qK8PT1jW5Z9keK5ElpUnELBDk7g%3D&reserved=0. You are receiving this because you were assigned.Message ID: @.***>
Got it! Thanks! I've been trying to find a way to generate points with some randomness but have a given regression line. It's taking a bit more time than I expected, but I'll keep working on it.
Could you just start with a test on a "fixed" set of data?
Tanya Byker
Associate Professor, Economics
Middlebury College @.**@.>
From: Wayne Wang @.> Sent: Thursday, June 16, 2022 10:30 PM To: ProfessorAmanda/econsimulations @.> Cc: Byker, Tanya S. @.>; Assign @.> Subject: Re: [ProfessorAmanda/econsimulations] New Module: Measurement Error (Issue #282)
Got it! Thanks! I've been trying to find a way to generate points with some randomness but have a given regression line. It's taking a bit more time than I expected, but I'll keep working on it.
— Reply to this email directly, view it on GitHubhttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FProfessorAmanda%2Feconsimulations%2Fissues%2F282%23issuecomment-1158418769&data=05%7C01%7Ctbyker%40middlebury.edu%7C2de8959275da47aa4b9308da50095b46%7Ca1bb0a191576421dbe93b3a7d4b6dcaa%7C1%7C0%7C637910298381990837%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=PP4O4pcNPlptRA5pJuFalMkh1G78Aws0g5AspNMZKqQ%3D&reserved=0, or unsubscribehttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAP65VZ742GPHDIAURWRDGPDVPPPMTANCNFSM5X7RR4KQ&data=05%7C01%7Ctbyker%40middlebury.edu%7C2de8959275da47aa4b9308da50095b46%7Ca1bb0a191576421dbe93b3a7d4b6dcaa%7C1%7C0%7C637910298381990837%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=jiYZw6qAZ48KlaOUfAvFmQmII6CND05IdGwtfBlDTHk%3D&reserved=0. You are receiving this because you were assigned.Message ID: @.***>
I think I got it work! I first plot the points on a line with a slope of +1, and then move them around randomly by a small amount. Now, with errors introduced in the X-direction, the slope indeed decreases! And with error in the Y-direction, the slope changes to both directions. I will try to implement this to the first part of the module as well, to ensure we have a large enough slope.
Do we want to show any equations related to this plotting?
Progress update: I've added the assurance of a strong slope to generated points to both parts, as well as input validation for the second part(make sure the number of iterations is between 1 and 100). Please let me know if there's anything that I should fix and tweak. Thanks!
Get started on a new module on measurement error! Here are some initial steps: