Question
(Please use R software A number of 200 schools were sampled according to a stratified sampling scheme, from a population of 6194 schools. The stratification
(Please use R software
A number of 200 schools were sampled according to a stratified sampling scheme, from a population of 6194 schools. The stratification variable ('Schtp') is the school type: Elementary/Middle/High School. The population contains 4421 elementary schools, 1018 middle schools and 755 high schools. The variables measured are: 'Prctst' (percentage of students tested) and 'Grth' (change in academic performance index from year 1999 to 2000). 'Wgt' is the weight variable.
Compute the estimates of the population means for the variables 'Prctst' and 'Grth', along with standard errors and 90% confidence intervals.
Note: The weight variable is already in the data set so there is no need to recreate it.
Note: In R define the 'fpc' variable as follows: fpc<-1:200; fpc[Schtp=="E"]<-4421; fpc[Schtp=="M"]<- 1018; fpc[Schtp=="H"]<- 755;
Note: The data set includes column names. An alternative to removing these names from the data file is as follows: In R read the data as: read.table("cap1.txt",header=T) In SAS, you'll need to include firstobs=2; in the 'data' statement, where you also define the variables
obs Schtp Prctst Grth Wgt 1 E 99 24 44.21 2 E 100 40 44.21 3 E 99 -13 44.21 4 E 100 44 44.21 5 E 100 61 44.21 6 E 100 25 44.21 7 E 99 -9 44.21 8 E 98 0 44.21 9 E 100 84 44.21 10 E 100 11 44.21 11 M 99 17 20.36 12 M 99 6 20.36 13 H 93 7 15.10 14 M 95 3 20.36 15 H 95 -10 15.10 16 E 100 57 44.21 17 E 98 66 44.21 18 M 100 45 20.36 19 M 95 51 20.36 20 E 100 56 44.21 21 E 100 20 44.21 22 M 98 28 20.36 23 E 100 22 44.21 24 H 99 52 15.10 25 H 99 5 15.10 26 E 100 16 44.21 27 H 98 8 15.10 28 H 98 -24 15.10 29 E 100 64 44.21 30 M 99 5 20.36 31 M 99 38 20.36 32 E 100 25 44.21 33 E 100 -3 44.21 34 E 100 34 44.21 35 H 97 -7 15.10 36 E 100 25 44.21 37 M 100 15 20.36 38 M 99 35 20.36 39 H 100 21 15.10 40 E 100 43 44.21 41 M 100 7 20.36 42 H 99 25 15.10 43 E 99 7 44.21 44 H 100 4 15.10 45 E 100 2 44.21 46 E 99 54 44.21 47 H 99 16 15.10 48 M 90 9 20.36 49 M 100 2 20.36 50 E 99 38 44.21 51 M 96 77 20.36 52 E 98 60 44.21 53 E 100 41 44.21 54 E 99 51 44.21 55 E 100 39 44.21 56 H 98 54 15.10 57 M 66 5 20.36 58 M 99 29 20.36 59 E 83 3 44.21 60 E 98 33 44.21 61 E 100 37 44.21 62 E 100 63 44.21 63 E 88 39 44.21 64 M 99 9 20.36 65 H 92 30 15.10 66 E 100 37 44.21 67 E 99 15 44.21 68 E 98 62 44.21 69 E 100 48 44.21 70 M 98 7 20.36 71 M 99 -13 20.36 72 E 99 -3 44.21 73 E 100 39 44.21 74 M 100 65 20.36 75 E 100 48 44.21 76 E 89 26 44.21 77 M 100 18 20.36 78 E 100 61 44.21 79 E 100 51 44.21 80 E 97 67 44.21 81 H 97 18 15.10 82 E 98 51 44.21 83 E 99 18 44.21 84 E 100 23 44.21 85 E 100 38 44.21 86 H 100 23 15.10 87 E 99 -10 44.21 88 M 99 4 20.36 89 H 99 24 15.10 90 E 99 20 44.21 91 E 100 50 44.21 92 E 100 40 44.21 93 E 99 64 44.21 94 M 99 57 20.36 95 E 99 56 44.21 96 H 97 -7 15.10 97 E 99 54 44.21 98 H 98 -2 15.10 99 M 97 4 20.36 100 E 100 -2 44.21 101 E 99 5 44.21 102 M 100 9 20.36 103 H 100 -17 15.10 104 M 96 40 20.36 105 E 99 55 44.21 106 E 99 70 44.21 107 H 97 -47 15.10 108 E 96 17 44.21 109 M 100 34 20.36 110 E 98 18 44.21 111 H 90 -16 15.10 112 M 100 5 20.36 113 H 97 82 15.10 114 E 98 18 44.21 115 M 100 27 20.36 116 H 98 4 15.10 117 E 99 14 44.21 118 E 100 73 44.21 119 M 99 60 20.36 120 M 99 55 20.36 121 E 99 3 44.21 122 H 99 -19 15.10 123 E 100 125 44.21 124 E 99 13 44.21 125 M 97 52 20.36 126 E 100 85 44.21 127 E 98 30 44.21 128 E 98 83 44.21 129 E 100 133 44.21 130 H 99 -31 15.10 131 M 100 4 20.36 132 M 100 19 20.36 133 H 97 -24 15.10 134 E 99 19 44.21 135 E 99 64 44.21 136 M 100 44 20.36 137 E 95 45 44.21 138 H 100 48 15.10 139 E 97 43 44.21 140 M 100 80 20.36 141 E 99 31 44.21 142 M 98 12 20.36 143 E 100 27 44.21 144 H 96 23 15.10 145 H 98 18 15.10 146 E 100 48 44.21 147 H 97 10 15.10 148 H 100 -2 15.10 149 E 100 55 44.21 150 H 100 35 15.10 151 M 99 19 20.36 152 E 100 2 44.21 153 E 99 52 44.21 154 M 99 41 20.36 155 E 98 68 44.21 156 M 100 6 20.36 157 M 99 5 20.36 158 M 98 57 20.36 159 H 97 3 15.10 160 E 100 60 44.21 161 M 98 38 20.36 162 E 99 93 44.21 163 H 99 40 15.10 164 H 86 -25 15.10 165 E 100 23 44.21 166 H 96 4 15.10 167 H 90 10 15.10 168 H 96 -21 15.10 169 H 93 11 15.10 170 M 99 30 20.36 171 M 100 30 20.36 172 E 98 60 44.21 173 M 98 31 20.36 174 H 90 20 15.10 175 M 100 13 20.36 176 H 89 25 15.10 177 H 99 -20 15.10 178 H 79 -1 15.10 179 E 97 -8 44.21 180 H 99 10 15.10 181 M 100 27 20.36 182 H 100 -7 15.10 183 E 100 46 44.21 184 M 99 29 20.36 185 E 100 -15 44.21 186 E 100 54 44.21 187 E 100 42 44.21 188 E 100 41 44.21 189 E 100 66 44.21 190 H 99 4 15.10 191 E 99 64 44.21 192 H 99 6 15.10 193 H 98 22 15.10 194 E 100 33 44.21 195 E 99 15 44.21 196 E 95 53 44.21 197 H 100 26 15.10 198 M 99 30 20.36 199 E 99 21 44.21 200 H 100 15 15.10
those data are four columns for example
obs=1
Schtp=E
Prctst=99
Grth=24
Wgt=44.21 so on
hint:
library(survey)
cap1<-read.csv(choose.files(),header=T) colnames(cap1)=c("obs" "Schtp" "Prctst" "Grth" "Wgt") attach(cap1) pr<-1:200; pr[Schtp==E]<-100/4421; pr[Schtp==M]<- 52/1018; pr[Schtp==h]<-49/755; Wgt<-1/pr; fpc<-pr; fpc<-1:200; fpc[Schtp=="E"]<-4421; fpc[Schtp=="M"]<- 1018; fpc[Schtp=="H"]<- 755; cap1.str<-svydesign(ids=~0, strata=~Schtp,weights=Wgt,fpc=~fpc,data=cap1) svymean(~ Prctst+Grth ,cap1.str)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started