forked from pmaurogut/SAE_course
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFigures.qmd
36 lines (31 loc) · 1.19 KB
/
Figures.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
---
title: "Small area estimation for foerst inventories"
author: "Francisco Mauro, Bryce Frank & Temesgen Hailemarian"
format: revealjs
editor: visual
---
# Figure1
```{r}
curve(1.96*10*1/sqrt(x),0,20,main="Confidence interval width vs sample size",ylab="Confidence interval width",xlab="sample size")
```
# Figure 2
```{r}
set.seed(1234)
x <- runif(100,0,20)
y <- rnorm(100,x+x*x,20)
model<-lm(y~x)
set.seed(5)
sample <- sample(100,10)
xs <- x[sample]
ys <- y[sample]
model2 <- lm(ys~xs)
plot(x,y, main="Population's best linear fit",xlab="Ayuxiliary variable", ylab="Variable of interest",pch=20,cex=0.5)
curve(model$coefficients[1] +model$coefficients[2] *x,col="red",add=TRUE)
plot(x,y, main="Population's best linear fit & estimated line",xlab="Ayuxiliary variable", ylab="Variable of interest",pch=20,cex=0.5)
curve(model$coefficients[1] +model$coefficients[2] *x,col="red",add=TRUE)
points(xs,ys,pch=20,col="blue",cex=2)
curve(model2$coefficients[1] +model2$coefficients[2] *x,col="blue",add=TRUE,lty=2)
legend("topleft",legend=c("Population fit","Estimated line"),lty=c(1,2),col=c("red","blue"))
legend("bottomright",legend=c("sample"),pch=20,col="blue")
# curve(x+0.5*x*x,col="blue",add=TRUE)
```