survey

Raking Multiple Imputed dataset

戏子无情 提交于 2021-02-20 02:14:36
问题 This is a continuation from my previous post Error with svydesign using imputed data sets I would like to run a rake() function in my imputed dataset. However, it seems it is not finding the input variable. Below is a sample code: library(mitools) library(survey) library(mice) data(nhanes) nhanes2$hyp <- as.factor(nhanes2$hyp) imp <- mice(nhanes2,method=c("polyreg","pmm","logreg","pmm"), seed = 23109) imp_list <- lapply( 1:5 , function( n ) complete( imp , action = n ) ) des<-svydesign(id=~1,

Raking Multiple Imputed dataset

不羁岁月 提交于 2021-02-20 02:11:46
问题 This is a continuation from my previous post Error with svydesign using imputed data sets I would like to run a rake() function in my imputed dataset. However, it seems it is not finding the input variable. Below is a sample code: library(mitools) library(survey) library(mice) data(nhanes) nhanes2$hyp <- as.factor(nhanes2$hyp) imp <- mice(nhanes2,method=c("polyreg","pmm","logreg","pmm"), seed = 23109) imp_list <- lapply( 1:5 , function( n ) complete( imp , action = n ) ) des<-svydesign(id=~1,

How to convert “svyrep.design”’ to a data.frame?

你离开我真会死。 提交于 2021-02-08 08:19:42
问题 I'd like to convert a svyrep.design / survey.design object in R into a data frame. I'm aware that this object would be quite large. library(survey) data(api) # loads "apiclus2" sample data dclus2 <- svydesign(id=~dnum+snum, weights=~pw, data=apiclus2) The above applies weights a data frame, turning it into a survey object. dclus2 = as.data.frame(dclus2) Error message: # Error in as.data.frame.default(dclus2) : # cannot coerce class ‘c("survey.design2", "survey.design")’ to a data.frame` I'd

How to convert “svyrep.design”’ to a data.frame?

冷暖自知 提交于 2021-02-08 08:18:10
问题 I'd like to convert a svyrep.design / survey.design object in R into a data frame. I'm aware that this object would be quite large. library(survey) data(api) # loads "apiclus2" sample data dclus2 <- svydesign(id=~dnum+snum, weights=~pw, data=apiclus2) The above applies weights a data frame, turning it into a survey object. dclus2 = as.data.frame(dclus2) Error message: # Error in as.data.frame.default(dclus2) : # cannot coerce class ‘c("survey.design2", "survey.design")’ to a data.frame` I'd

In Qualtrics, how do I hide a slider from being displayed until a response is given? thank you

喜夏-厌秋 提交于 2021-01-29 19:03:27
问题 In Qualtrics, how do I use Javascript to hide a slider from being displayed until a response is given? thank you! 来源: https://stackoverflow.com/questions/60143050/in-qualtrics-how-do-i-hide-a-slider-from-being-displayed-until-a-response-is-gi

How to make a loop over multiple columns with the svyby function of the survey package?

↘锁芯ラ 提交于 2021-01-27 06:09:21
问题 I have been trying many ways , but I am not getting to solve the problem. I found here, here and here, but I couldn’t adapt them to my problem. I would like to pass the combination of two string vectors where each element of 'pop' would be combined with each element of 'territ' and over a subset of the column “enroll” through a numeric vector (“enroll_lines”). So, there are three iterations inside the svyby function I want to do: two over a string vector and one iteration inside a subset

Manipulate list object into data frame

╄→尐↘猪︶ㄣ 提交于 2021-01-05 13:19:50
问题 library(survey) I have data such as this. I am using the survey package to produce the MEAN, SE and FREQ of each variables in the vector named vars. I am new to manipulating lists in R & would really appreciate help! df <- data.frame( married = c(1,1,1,1,0,0,1,1), pens = c(0, 1, 1, NA, 1, 1, 0, 0), weight = c(1.12, 0.55, 1.1, 0.6, 0.23, 0.23, 0.66, 0.67)) vars <- c("weight","married","pens") design <- svydesign(ids=~1, data=df, weights=~weight) myfun <- function(x){ means <- svymean(as

Manipulate list object into data frame

为君一笑 提交于 2021-01-05 13:18:40
问题 library(survey) I have data such as this. I am using the survey package to produce the MEAN, SE and FREQ of each variables in the vector named vars. I am new to manipulating lists in R & would really appreciate help! df <- data.frame( married = c(1,1,1,1,0,0,1,1), pens = c(0, 1, 1, NA, 1, 1, 0, 0), weight = c(1.12, 0.55, 1.1, 0.6, 0.23, 0.23, 0.66, 0.67)) vars <- c("weight","married","pens") design <- svydesign(ids=~1, data=df, weights=~weight) myfun <- function(x){ means <- svymean(as