eugen pircalabelu
2007-Dec-19 07:39 UTC
[R] 4 questions regarding hypothesis testing, survey package, ts on samples, plotting
Good morning! I have 4 questions which trouble me: 1. I want to test the hypothesis that the 2 proportions (the mean of a binomial) which come from 2 different samples are equal. I want to use the following function z= (p1-p2)/ sqrt((p1(1-p1)/n1)+(p2(1-p2)/n2)) which is one of the standard formulas for this case. Is there such a function in R? p1=the proportion from the first sample n1=the first sample size p1=the proportion from the second sample n2=the second sample size 2. How can i find the median of a variable in survey package? a<-c(1:10) b<-sample(1:20, 10, replace=T) b1<-sample(0:1, 10, replace=T) c<-data.frame(a,b, b1) library(survey) design<-svydesign(id=~1, data=c) svymean(~b, design) svymean gives me the mean, but what function gives me the svymedian, and what function gives me the svyproportion for b1? I want to know the median for a metric variable and the proportion for a binomial variable ? 3. Could time series analysis (arima/arma) be applied on data that are obtained from a sample?. Eg: Say I have data from the same sample in 40 moments. Could I use arima/arma on the series? Or must i have data for the whole population like data from the Statistical Office on investment, inflation, demographics and so on? 4. I want to modify the scale of my axes within a plot but i really could not find this option. I think there is such an option, but i can not find it. x<-rnorm(100, 100, 3) x<-ts(x, frequency=12) acf(x) plot(x) On the above example, i want to a scale like this 95,96,97,98,....104,105 (on y) and 1,2,3,4,...7,8 (on x). Thank you very much and have a great day! --------------------------------- [[alternative HTML version deleted]]
James Reilly
2007-Dec-19 09:50 UTC
[R] 4 questions regarding hypothesis testing, survey package, ts on samples, plotting
On 19/12/07 8:39 PM, eugen pircalabelu wrote:> 2. How can i find the median of a variable in survey package? > a<-c(1:10) > b<-sample(1:20, 10, replace=T) > b1<-sample(0:1, 10, replace=T) > c<-data.frame(a,b, b1) > library(survey) > design<-svydesign(id=~1, data=c) > svymean(~b, design) > > svymean gives me the mean, but what function gives me the svymedian, and what function gives me the svyproportion for b1? > I want to know the median for a metric variable and the proportion for a binomial variable ?The svyquantile function will give you the median, e.g. svyquantile(~b, design, 0.5, interval.type="score") Since a proportion is just the mean of a 0/1 variable, you can use svymean for that, e.g. svymean(~b1, design) HTH, James -- James Reilly Department of Statistics, University of Auckland Private Bag 92019, Auckland, New Zealand
David Winsemius
2007-Dec-20 14:17 UTC
[R] 4 questions regarding hypothesis testing, survey package, ts on samples, plotting
eugen pircalabelu <eugen_pircalabelu at yahoo.com> wrote in news:187205.27181.qm at web38605.mail.mud.yahoo.com: >> I have 4 questions which trouble me: >snip 1-3> > 4. I want to modify the scale of my axes within a plot but i really > could not find this option. I think there is such an option, but i > can not find it. > x<-rnorm(100, 100, 3) > x<-ts(x, frequency=12) > acf(x) > plot(x) > On the above example, i want to a scale like this > 95,96,97,98,....104,105 (on y) and 1,2,3,4,...7,8 (on x).Instead of looking at ?plot, try: ?plot.default # see the xlim and ylim arguments. -- David Winsemius