Sample Stata output with notes

advertisement
Sample Stata output
___ ____ ____ ____ ____ (R)
/__
/ ____/ / ____/
___/ / /___/ / /___/ 13.1 Copyright 1985-2013 StataCorp LP
Statistics/Data Analysis
StataCorp
4905 Lakeway Drive
Special Edition
College Station, Texas 77845 USA
800-STATA-PC
979-696-4600
http://www.stata.com
stata@stata.com
979-696-4601 (fax)
Single-user Stata perpetual license:
Serial number: 401306204974
Licensed to: Darryl McLeod
Fordham University
Notes:
1. (/v# option or -set maxvar-) 5000 maximum variables
. doedit "E:\Users\dlm7\Downloads\sumaria (1).do"
. do "C:\Users\dlm7\AppData\Local\Temp\STD00000000.tmp"
. use "E:\sumaria2011", clear
.
end of do-file
. do "C:\Users\dlm7\AppData\Local\Temp\STD00000000.tmp"
. use "E:\sumaria2011", clear
.
end of do-file
. do "C:\Users\dlm7\AppData\Local\Temp\STD00000000.tmp"
. svyset conglome [pw=facpob], strata(estrato)
pweight: facpob
VCE: linearized
Single unit: missing
Strata 1: estrato
SU 1: conglome
FPC 1: <zero>
.
end of do-file
. do "C:\Users\dlm7\AppData\Local\Temp\STD00000000.tmp"
. tabstat gpcm [aw=facpob], stats(mean semean sd n )
variable |
mean se(mean)
sd
N
-------------+---------------------------------------gpcm | 484.6624 2.556388 402.6534
------------------------------------------------------
.
end of do-file
24809
. do "C:\Users\dlm7\AppData\Local\Temp\STD00000000.tmp"
. tabstat linpe if (estrato>=1) [aw=facpob], stats(mean semean p50)
variable |
mean se(mean)
p50
-------------+-----------------------------linpe | 143.0299 .1328722 137.7326
--------------------------------------------
.
end of do-file
. do "C:\Users\dlm7\AppData\Local\Temp\STD00000000.tmp"
. tabstat linpe if (estrato<6) [aw=facpob], stats(mean semean p50)
variable |
mean se(mean)
p50
-------------+-----------------------------linpe | 150.6009 .1561769 143.5867
--------------------------------------------
.
end of do-file
. do "C:\Users\dlm7\AppData\Local\Temp\STD00000000.tmp"
. tabstat linpe if (estrato>=6) [aw=facpob], stats(mean semean p50)
variable |
mean se(mean)
p50
-------------+-----------------------------linpe | 121.2698 .0161088 121.4675
--------------------------------------------
.
end of do-file
. do "C:\Users\dlm7\AppData\Local\Temp\STD00000000.tmp"
. tabstat linea if (estrato>=1) [aw=facpob], stats(mean semean p50)
variable |
mean se(mean)
p50
-------------+-----------------------------linea | 272.2597 .3591983 275.7272
--------------------------------------------
.
end of do-file
. do "C:\Users\dlm7\AppData\Local\Temp\STD00000000.tmp"
. tabstat linea if (estrato<6) [aw=facpob], stats(mean semean p50)
variable |
mean se(mean)
p50
-------------+-----------------------------linea | 296.3015 .3693753 277.5714
--------------------------------------------
.
end of do-file
. do "C:\Users\dlm7\AppData\Local\Temp\STD00000000.tmp"
. tabstat linea if (estrato>=6) [aw=facpob], stats(mean semean p50)
variable |
mean se(mean)
p50
-------------+-----------------------------linea | 203.1609 .0766447 200.8827
--------------------------------------------
.
end of do-file
. do "C:\Users\dlm7\AppData\Local\Temp\STD00000000.tmp"
. sepov gpcm [w=facpob], povline(linea)
unrecognized command: sepov
r(199);
end of do-file
r(199);
. do "C:\Users\dlm7\AppData\Local\Temp\STD00000000.tmp"
. sepov gpcm [w=facpob], povline(linea)
(sampling weights assumed)
Poverty measures for the variable gpcm: (unlabeled)
Survey mean estimation
pweight: facpob
Number of obs
Strata: <one>
PSU:
=
24809
Number of strata =
<observations>
1
Number of PSUs =
24809
Population size = 29943619
-----------------------------------------------------------------------------Mean | Estimate
Std. Err. [95% Conf. Interval]
Deff
---------+-------------------------------------------------------------------p0 | .2782429
.00415
.2701086
.2863772
2.127523
p1 | .0780467
.0014051
.0752928
.0808007
1.902044
p2 | .0318401
.0007396
.0303904
.0332898
1.827785
------------------------------------------------------------------------------
.
end of do-file
. do "C:\Users\dlm7\AppData\Local\Temp\STD00000000.tmp"
. sepov gpcm [w=facpob] if (estrato<6), povline(linea)
(sampling weights assumed)
Poverty measures for the variable gpcm: (unlabeled)
Survey mean estimation
pweight: facpob
Number of obs
=
15065
Strata: <one>
PSU:
Number of strata =
<observations>
1
Number of PSUs =
15065
Population size = 22214450
-----------------------------------------------------------------------------Mean | Estimate
Std. Err. [95% Conf. Interval]
Deff
---------+-------------------------------------------------------------------p0 | .1799882
.0048984
.1703869
.1895896
2.448933
p1 | .0400419
.0014403
.0372188
.042865
2.561502
p2 | .0138027
.0006963
.0124379
.0151675
2.724085
------------------------------------------------------------------------------
.
end of do-file
. do "C:\Users\dlm7\AppData\Local\Temp\STD00000000.tmp"
. sepov gpcm [w=facpob] if (estrato>=6), povline(linea)
(sampling weights assumed)
Poverty measures for the variable gpcm: (unlabeled)
Survey mean estimation
pweight: facpob
Strata: <one>
PSU:
<observations>
Number of obs
=
9744
Number of strata =
Number of PSUs =
Population size = 7729168.5
1
9744
-----------------------------------------------------------------------------Mean | Estimate
Std. Err. [95% Conf. Interval]
Deff
---------+-------------------------------------------------------------------p0 | .5606372
.0062727
.5483413
.5729331
1.556334
p1 | .1872767
.002944
.1815059
.1930476
1.737225
p2 | .0836816
.0018121
.0801295
.0872337
1.834893
------------------------------------------------------------------------------
.
end of do-file
. do "C:\Users\dlm7\AppData\Local\Temp\STD00000000.tmp"
. sepov gpcm [w=facpob], povline(linpe)
(sampling weights assumed)
Poverty measures for the variable gpcm: (unlabeled)
Survey mean estimation
pweight: facpob
Number of obs
Strata: <one>
PSU:
=
24809
Number of strata =
<observations>
1
Number of PSUs =
24809
Population size = 29943619
-----------------------------------------------------------------------------Mean | Estimate
Std. Err. [95% Conf. Interval]
Deff
---------+-------------------------------------------------------------------p0 | .0634228
.0019537
.0595934
.0672523
1.594156
p1 | .0149874
.0005739
.0138625
.0161122
1.588561
p2 | .0053678
.0002667
.0048451
.0058906
1.497365
------------------------------------------------------------------------------
.
end of do-file
. do "C:\Users\dlm7\AppData\Local\Temp\STD00000000.tmp"
. sepov gpcm [w=facpob] if (estrato<6), povline(linpe)
(sampling weights assumed)
Poverty measures for the variable gpcm: (unlabeled)
Survey mean estimation
pweight: facpob
Number of obs
Strata: <one>
PSU:
=
15065
Number of strata =
<observations>
1
Number of PSUs =
15065
Population size = 22214450
-----------------------------------------------------------------------------Mean | Estimate
Std. Err. [95% Conf. Interval]
Deff
---------+-------------------------------------------------------------------p0 | .0141625
.0015339
.0111558
.0171693
2.538724
p1 | .0027967
.0004132
.0019867
.0036066
2.922182
p2 | .0008881
.0001642
.0005662
.0012099
2.583605
------------------------------------------------------------------------------
.
end of do-file
. do "C:\Users\dlm7\AppData\Local\Temp\STD00000000.tmp"
. sepov gpcm [w=facpob] if (estrato>=6), povline(linpe)
(sampling weights assumed)
Poverty measures for the variable gpcm: (unlabeled)
Survey mean estimation
pweight: facpob
Number of obs
Strata: <one>
PSU:
=
9744
Number of strata =
<observations>
1
Number of PSUs =
9744
Population size = 7729168.5
-----------------------------------------------------------------------------Mean | Estimate
Std. Err. [95% Conf. Interval]
Deff
---------+-------------------------------------------------------------------p0 | .2050021
.0055135
.1941946
.2158097
1.817265
p1 | .0500248
.001753
.0465885
.0534611
1.902171
p2 | .0182432
.0008841
.0165102
.0199762
1.957318
------------------------------------------------------------------------------
.
end of do-file
.
R command file
# how to set a directory? to run command in R highlight and right click with mouse
setwd("E:/Users/dlm7/desktop/Dropbox/fordham")
# how to get a directory?
getwd()
# how to read a stata file? comment go to Packages and select "load package"
# choose "foreign" and download foreign package - Read Stata file in R Software
# for example stata file: sumaria2011.dta, mus08psidextract.dta, etc
# reading the stata with Peru 2011 survey stores data now in with "c" in R software
c<-read.dta("E:/sumaria2011.dta")
# Use this to check the data, and summarize all in "c"
summary(c)
# now got to packages to download and then instal the "survey" package - first
# install packages Data survey, # choose langage CA (2) and then choose "survey"
# download and go to "load packages" and choose survey
poverty<-svydesign(id=~conglome, strata=~estrato, weights=~facpob, data=c)
#this load c into poverty in a weighted average form match svyset in STATA
# computes the mean of gross per capita monthly exp using design=poverty population
# survey design
monthly_percapita_expenditure<-svymean(~gpcm, design=poverty)
monthly_percapita_expenditure<-(~gpcm, design=poverty)
#when we use this we get about the same SE as in Stata
sd(c$gpcm)/sqrt(24809)
#now show what the mean and SE is, note that this is different than
monthly_percapita_expenditure
# download ineq package - Poverty package
# mean monthly percapita expenditure - poverty line National
#tabstat gpcm [aw=facpob], stats(mean semean sd n )
#
variable |
mean se(mean)
sd
N
#-------------+---------------------------------------#
gpcm | 484.6624 2.556388 402.6534
24809
# Stat has the mean but standard errot in R = 5.3645
linea<-svymean(~linea, design=poverty)
linea
# mean monthly percapita expenditure - extreme poverty line National
linpe<-svymean(~linpe, design=poverty)
linpe
# again only SE is different in R we get .83 SE but same mean
# variable |
mean se(mean)
p50
#-------------+-----------------------------#
linea | 272.2597 .3591983 275.7272
# National extreme poverty headcount
pov(c$gpcm, 143.03, parameter=1, type ="Foster")
# National poverty headcount
pov(c$gpcm, 272.26, parameter=1, type ="Foster")
C:\Users\dlm7\AppData\Local\Temp\RtmpyGprtd\downloaded_packages
> local({pkg <- select.list(sort(.packages(all.available = TRUE)),graphics=TRUE)
+ if(nchar(pkg)) library(pkg, character.only=TRUE)})
> pov(c$gpcm, 143.03, parameter=1, type ="Foster")
Error: could not find function "pov"
> local({pkg <- select.list(sort(.packages(all.available = TRUE)),graphics=TRUE)
+ if(nchar(pkg)) library(pkg, character.only=TRUE)})
> pov(c$gpcm, 143.03, parameter=1, type ="Foster")
[1] 0.1050022
> linpe<-svymean(~linpe, design=poverty)
> linpe
mean
SE
linpe 143.03 0.3305
> linpelinpe<-mean(~linpe)
Warning message:
In mean.default(~linpe) : argument is not numeric or logical: returning NA
> linpe<-mean(~c$linpe)
Warning message:
In mean.default(~c$linpe) :
argument is not numeric or logical: returning NA
> linpe<-mean(c$linpe)
> linpe
[1] 134.3793
> pov(c$gpcm, 272.26, parameter=1, type ="Foster")
[1] 0.3374179
>
Download