Displaying 6 results from an estimated 6 matches for "srswor".
2009 Oct 01
5
How to use Subpopulation data?
...g three methods and now i want to calculate the statistics but i only get the population parameters.
H <- matrix(rnorm(100, mean=50000, sd=5000))
sampleframe=data.frame(type=c(rep("H",100)),value=c(H))
sampleframe
str=strata(sampleframe,c("type"),size=c(20,), method="srswor")
sample.strat<-getdata(sampleframe,str)
sample.strat
length(H)
i get:
length(H)
[1] 100
Desire to get:
length(H)
[1] 20
Best Regards
[[alternative HTML version deleted]]
2012 Feb 01
1
package sampling, function strata
...atified random samples from a population of
>3900 cells. I have 41 strata and I have to draw a different number of
samples from them(between 2 and 8).
I have tried to apply the funtion strata following the instruction in
the manual:
strata(dataframe, stratanames=NULL, size, method=c("srswor"),
pik,description=TRUE)
but I get the error message
Error in data.frame((1:nrow(data))[srswor(size, nrow(data)) == 1], rep(size/nrow(data), :
arguments imply differing number of rows: 3, 122
My stratanames and size vectors have the same length, 41 (the number of strata), and 122 is th...
2010 Feb 05
2
Random number quality
Hello,
I'm running R 2.10.1 on Windows Vista. I'm selecting a random sample of
several hundred items out of a larger population of several thousand. I
realize there is srswor() in package sampling for exactly this purpose, but
as far as I can tell it uses the native PRNG which may or may not be random
enough. Instead I used the random package which pulls random numbers from
random.org, although in my extended reading [vignette("random-intro",
package="ra...
2013 Apr 26
1
Stratified Random Sampling Proportional to Size
...2
17 ST S 6 0
#THEN I attempted to use sampling::strata using the instructions in that package and got an error
#I use stratum_cp$stratp for my sizes.
> s<-strata(CURRPOP,c("APPT_TYP_CD_LL","EMPL_TYPE"),size=stratum_cp$stratp,method="srswor")
Error in data.frame(..., check.names = FALSE) :
arguments imply differing number of rows: 0, 1
> traceback()
5: stop("arguments imply differing number of rows: ", paste(unique(nrows),
collapse = ", "))
4: data.frame(..., check.names = FALSE)
3: cbind(de...
2007 Mar 28
1
(no subject)
Hallo,
I'm trying to sample a matrix with simple random sampling without
replacement but seem to have a problem with the matrix length. Both
sample() and srswor() use length() which returns the number of columns in
matrix. This means that to function it seems that the sample size exceeds
the matrix length. I need to sample the whole matrix for there are
auxiliary variables I need for further sample processing. Ay help is much
appreciated.
Regards,
Katja L...
2008 Aug 25
1
How to run a model 1000 times, while saving coefficients each time?
...led results.
We have a looping structure (also below) but we do not know how to save
the coefficients and R2 values. We are missing some code (indicated)
Any assistance would be greatly appreciated.
Thanks,
library(sampling)
mall<-read.csv("mall.csv")
for (j in 1:1000) {
s<-srswor(2840,3550)
mall80<-mall[s==1,]
mall20<-mall[s==0,]
model1<-lm(count~habitat,data=mall80)
summary(model1)
mall20$predicted<-predict(model1,newdata=mall20)
model2<-lm(count~predicted,data=mall20)
MISSING CODE: SAVE MODEL COEFFICIENTS AND R2 VALUE TO A DATAFRAME CALLED
RESULTS
}