Statistics 板


LINE

如果是跟統計軟體有關請重發文章,使用程式做為分類。 統計軟體,如SPSS, AMOS, SAS, R, STATA, Eviews,請都使用程式做為分類 請詳述問題內容,以利板友幫忙解答,過短文章依板規處置,請注意。 為避免版面混亂,請勿手動置底問題,擅用E做檔案編輯 我人在國外,這學期的統計必修課是我完全沒學過的R,英文加上統計加上新軟體,真的 很吃力啊.... 以下問題是英文的,我已經花了一整天試著理解但仍有很多疑問,主要是 我不知道我該餵給R什麼訊息讓它去跑 因為這週得了flu所以缺課,頭腦昏沉沉的理解困難,實在無法才上來請高手幫忙指點 老師給的問題如下: Identify an experimental study with a treatment group, a control group, and some binary outcome (some sort of success/failure outcome) and calculate the power for that experiment with different reasonable effect sizes (say, 5%, 10%, or 15%). Check your work using a power calculator (take a screenshot of the calculator or provide me with the information I need to check what you found). If you are having difficulty identifying an experiment, you can use the Minneapolis Domestic Violence Experiment; the results for that experiment are summarized here: https://www.policefoundation.org/publication/the-minneapolis-domestic-violence-experiment/ If you use the Minneapolis Domestic Violence Experiment, be sure to compare the arrest treatment to both of the non-arrest treatments (separate and mediate) combined. Also, you can use the code I sent but if you run into difficulty with the rounding error problem, send me your code and I will help you troubleshoot it. 他給的R code如下: # p(fail|treatment) and p(fail|control) pftrt <- 0.5 pfctl <- 0.6 # generate the failure variable fail <- c(rep("yes",pftrt*treatment.table[2]), rep("no",(1-pftrt)*treatment.table[2]), rep("yes",pfctl*treatment.table[1]), rep("no",(1-pfctl)*treatment.table[1])) # create the data frame. all <- data.frame(treatment,fail) # crosstable of failure by treatment. ctable <- table(all$fail,all$treatment) ctable # count the number of cases failing in each group. fc <- ctable[2,1] ft <- ctable[2,2] c(fc,ft) # count the total number of cases in each group. nc <- ctable[1,1]+ctable[2,1] nt <- ctable[1,2]+ctable[2,2] c(nc,nt) # calculate the failure rates in each group. pc <- fc/nc pt <- ft/nt c(pc,pt) # calculate the classical treatment effect # for the entire population. cte_pop <- pt-pc cte_pop # now we move to the sample and power assessment. # define the number of samples we will draw. nsamples <- 100000 # and the sample size for each of the samples is sampsize <- 500 # need an output vector for the cte and se(cte) scte <- vector() se_scte <- vector() # this is a for() loop that will run nsamples times. for(i in 1:nsamples) { c <- sample( 1:popsize, size=sampsize, replace=T ) strt <- all$treatment[c] sfail <- all$fail[c] stable <- table(sfail,strt) sfc <- stable[2,1] sft <- stable[2,2] snc <- stable[1,1]+stable[2,1] snt <- stable[1,2]+stable[2,2] spc <- sfc/snc spt <- sft/snt scte[i] <- spt-spc spooledp <- (sfc+sft)/(snc+snt) se_scte[i] <- sqrt( spooledp*(1-spooledp)* (1/snc+1/snt) ) } # let's look at some of the output # from the final sample. stable spt spc scte[nsamples] se_scte[nsamples] # here is a chart summarizing the # sampling distribution. par(mfrow=c(1,2)) boxplot(scte) hist(scte,prob=T,ylim=c(0,10)) lines(density(scte),lty=1,lwd=2) # here are some descriptive statistics for the # sampling distribution. mean(scte) sd(scte) quantile(scte,0.025) quantile(scte,0.975) # this is a vector of z-statistics for testing # the hypothesis that the population cte is 0 ztest <- scte/se_scte # Identify critical region of z-distribution qnorm(0.025) qnorm(0.975) # Decision rule decision <- ifelse( ztest<(-1.959964) | ztest>1.959964, "reject Ho","fail to reject Ho" ) # summarize the decisions table(decision) 好,我的問題首先是我實在分辨不出什麼資訊在那篇文章裡是我需要輸入給R的 我現在只知道要餵給它sample size,可是在文章裡的table 1,我分辨不出 failure/success outcomes,導致我無法給pftrt和pfctl明確的rates 我自己有試著去找另一篇比較沒那麼複雜的experiment study,但不確定是否能用 https://goo.gl/fhr1r9 第二個問題是,當我要調整effect sizes到5%,10%,15%,我是要同時調整 qnorm和quantile嗎? 文章很長,我的頭很昏(昨晚才剛退燒),如果有高手願意指點的話就太好了,感恩 --



※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 174.194.15.13
※ 文章網址: https://webptt.com/m.aspx?n=bbs/Statistics/M.1508953561.A.327.html
1F:→ andrew43: 你可以先處理最後算power的code。 10/26 09:57
2F:→ jupit: 作業的話,建議可以去soho或part-time版找協助會比較適合 10/26 20:52
3F:推 ppm2013: R shiny 02/08 01:38







like.gif 您可能會有興趣的文章
icon.png[問題/行為] 貓晚上進房間會不會有憋尿問題
icon.pngRe: [閒聊] 選了錯誤的女孩成為魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一張
icon.png[心得] EMS高領長版毛衣.墨小樓MC1002
icon.png[分享] 丹龍隔熱紙GE55+33+22
icon.png[問題] 清洗洗衣機
icon.png[尋物] 窗台下的空間
icon.png[閒聊] 双極の女神1 木魔爵
icon.png[售車] 新竹 1997 march 1297cc 白色 四門
icon.png[討論] 能從照片感受到攝影者心情嗎
icon.png[狂賀] 賀賀賀賀 賀!島村卯月!總選舉NO.1
icon.png[難過] 羨慕白皮膚的女生
icon.png閱讀文章
icon.png[黑特]
icon.png[問題] SBK S1安裝於安全帽位置
icon.png[分享] 舊woo100絕版開箱!!
icon.pngRe: [無言] 關於小包衛生紙
icon.png[開箱] E5-2683V3 RX480Strix 快睿C1 簡單測試
icon.png[心得] 蒼の海賊龍 地獄 執行者16PT
icon.png[售車] 1999年Virage iO 1.8EXi
icon.png[心得] 挑戰33 LV10 獅子座pt solo
icon.png[閒聊] 手把手教你不被桶之新手主購教學
icon.png[分享] Civic Type R 量產版官方照無預警流出
icon.png[售車] Golf 4 2.0 銀色 自排
icon.png[出售] Graco提籃汽座(有底座)2000元誠可議
icon.png[問題] 請問補牙材質掉了還能再補嗎?(台中半年內
icon.png[問題] 44th 單曲 生寫竟然都給重複的啊啊!
icon.png[心得] 華南紅卡/icash 核卡
icon.png[問題] 拔牙矯正這樣正常嗎
icon.png[贈送] 老莫高業 初業 102年版
icon.png[情報] 三大行動支付 本季掀戰火
icon.png[寶寶] 博客來Amos水蠟筆5/1特價五折
icon.pngRe: [心得] 新鮮人一些面試分享
icon.png[心得] 蒼の海賊龍 地獄 麒麟25PT
icon.pngRe: [閒聊] (君の名は。雷慎入) 君名二創漫畫翻譯
icon.pngRe: [閒聊] OGN中場影片:失蹤人口局 (英文字幕)
icon.png[問題] 台灣大哥大4G訊號差
icon.png[出售] [全國]全新千尋侘草LED燈, 水草

請輸入看板名稱,例如:Tech_Job站內搜尋

TOP