78 questions
Best practices
1
vote
1
replies
91
views
Calculate sample size in R - Longitudinal repeated measures study using a linear mixed effects model
I'm trying to calculate a sample size for a phychological study where the purpose of the study is to see if patients can maintain a score at baseline during 3 follow up measurements.
The mean baseline ...
0
votes
0
answers
23
views
Power analysis for multiple regression with binary moderator - Determining sample size
I want to conduct an a priori power analysis to determine the necessary sample size for a proposed project. I will estimate a regression between two continuous variables with a binary moderator (...
0
votes
0
answers
24
views
Suggestions to look for statistically significant trends with small numerators and large denominators
My company sells a large number of medical device implants per year. There are often "incidents" or minor issues, associated with them that can be easily categorized into an incident ...
-1
votes
1
answer
118
views
Sample size calculation for a multicenter RCT using a mixed effects model using simulated data in R [closed]
I am currently setting up a multicenter RCT of a treatment versus placebo (1:1), with a primary outcome of prolongation of pregnancy in days. The minimal clinically relevant difference in days is 5 ...
0
votes
0
answers
172
views
Repetitions on the same combination of factors in mixed ANOVA and its power analysis
I am trying to decide the appropriate model and perform power analysis. Suppose a data contains 2 groups (A,B) and 28 participants from each group. All of those participants are measured 15 times on ...
0
votes
0
answers
181
views
Quantile regression and sample size for a given tau
I am performing the quantile regression in R on a non linear model. I am getting the coefficients for the desired quantiles (tau = 0.05, 0.50, 0.95).
All very nice, but running the code without ...
0
votes
0
answers
27
views
reason for difference in power.prop.test and epiR::epi.sscompb results
I was trying to rework the examples in Epidemiology Study Design and Data Analysis by Mark Woodward using R.
Example 8.12 deals with calculation of sample size to test for a population proportion of ...
1
vote
1
answer
245
views
How to calculate sample size with R applying mixed model design [closed]
I would have a neuroimaging study (this possibly might be aside or help to figure out the problem). Participants are called to fill out a questionnaire, that turns a score in terms of technology usage....
0
votes
0
answers
292
views
How to avoid overlapping labels and error bars on a stacked bar plot (ggplot)?
I am trying to create a stacked bar plot with both error bars and sample sizes in R, using ggplot, geom_bar, and geom_errorbar. The labels and error bars are overlapping, and I'm trying to avoid that.
...
0
votes
0
answers
34
views
Error: Error in if (sum1 <= alpha && sum2 >= 1 - beta) { : missing value where TRUE/FALSE needed
`There exists r such that:
\sum_{i=r}^{n}{\left(\frac{n!}{i!(n-i)!}\right)\left(\pi_0^i\right){(1-\pi_0)}^{\left(n-i\right)}\le\alpha}
\sum_{i=r}^{n}{\left(\frac{n!}{i!(n-i)!}\right)\left(\pi_1^i\...
0
votes
2
answers
5k
views
Chi-square test in R with unequal sample sizes
A version of this question has been asked a few times but never in the simplest way. Basically, the stats::chisq.test function doesn't work when the sample sizes between the two groups are uneven, ...
1
vote
0
answers
1k
views
sample size calculation between 3 groups
I would like to calculate a sample size for 3 groups based on the mean for each of the three groups of an continuous variable (Flow per min).
Its a randomised study with an allocation ratio of 1:1:1. ...
2
votes
0
answers
288
views
Sample size formula for comparing more than 2 proportions
I have one control group and two treatment groups.
I know the sample size formulae for comparing two proportions.
n = (Zα/2+Zβ)2 * (p1(1-p1)+p2(1-p2)) / (p1-p2)2,
Can someone please help me what the ...
1
vote
1
answer
63
views
Cross multiplication to equalize sample proportions
I have a larger dataset and below is a subset of that data. The category is the dependent variable and Day_1 and Day_2 are independent variables.
ID <- c("e-1", "e-2", "e-3&...
0
votes
1
answer
3k
views
How to add count (n) / summary statistics as a label to ggplot2 boxplots?
I am new to R and trying to add count labels to my boxplots, so the sample size per boxplot shows in the graph.
This is my code:
bp_east_EC <-total %>% filter(year %in% c(1977, 2020, 2021, ...
-1
votes
1
answer
205
views
ggplo2 sample size annotation: How do you place the sample size under the x-axis?
I tried with the "solutions" from other posts without success. So, I am trying to add to my ggplot2 barplot the sample size per group under the names at the x-axis. I am using the ...
1
vote
1
answer
581
views
R: choose the right plot to create a line chart with 3 subgroups, sample size for each point, and significance differences between the subgroups
I'm trying to create a line plot like this one (made on Powerpoint):
showing the dependency of weight on age (weight~age), for 3 subgroups (so each group has its own line). I also want the chart to ...
0
votes
1
answer
158
views
Print sample size outside of boxplot boundary with ggplot in R
I'd like to display the sample size of each species on my boxplot, but the plot is fairly cluttered. Is there a way to display the sample size on the "outside" of the plot with "N" ...
1
vote
1
answer
1k
views
How to find non-NA values (sample size) of a large data frame?
I have a large data frame that contains lots of NAs. The rows are soil samples from different plots, and the columns are chemical variables. I wanted to create a column or data frame with the sample ...
1
vote
2
answers
383
views
changing null hypothesis value for sample size calculation of a single AUC
I am trying to get the sample size for a single AUC using power.roc.test in the pROC package. For example, the expected AUC is 0.97 (alternative hypothesis) and the value I am comparing to is 0.95 (...
1
vote
1
answer
70
views
Using second axis to display sample size for grouped data. Can't get spacing right so dot plot aligns with grouped bars in base R
I have grouped data, where every one of the bars has a different sample size, ranging from 0 samples to >600. I would like to have 2 more panels of this same graph for different data, and that ...
0
votes
2
answers
278
views
How to simulate different sample size for many times and calculate the sum for each sample size
Here is my code :
for (p in 1:10){
sample=rgamma(p,p,1)}
Here is what I get
[1] 1.841629
[1] 2.174076 1.410500
[1] 2.398601 4.674819 2.679830
[1] 2.736786 3.767747 4.546256 3.851677
[1] 4.204808 8....
0
votes
0
answers
462
views
Errors using powerSim and powerCurve for a clmm in R
I'm new to clmm and run into the following problem:
I want to obtain the optimal sample size for my study with R using powerSim and powerCurve. Because my data is ordinal, I'm using a clmm. Study ...
0
votes
1
answer
673
views
Selecting the sample size of each bootstrap sample
I have a dataframe with about 1700 observations (rows) in 29 variables (columns) and I have to select a mixture of 7 of these observations for which the weighted mean (of each variable) is as equal as ...
0
votes
0
answers
221
views
sample size for a single arm study based on median time to event
In my master thesis, I need to determine and calculate the number of cases for median time to event. The method is according to Brookmeyer & Crowley, 1982. My question is: How can I determine the ...
5
votes
1
answer
1k
views
Why R pwr.2p.test gives different sample size than G*Power?
I want to know the sample size required. In R
library(pwr)
pwr.2p.test(h = ES.h(0.022,0.001),sig.level = 0.05,power = 0.8,alternative = "greater")
gives the results
Difference of ...
0
votes
1
answer
424
views
Calculate `eta` for sample size calculation using power anova
I am using pingouin.power_anova(eta=None, k=None, n=None, power=None, alpha=0.05) in python for the calculation of sample size.
I have the information about control_group_historic_mean, ...
2
votes
1
answer
466
views
Sample size calculation for experimental design
I have three treatments (Wild type, Mutant1 and Mutant2); I request inputs on how to decide the sample size that would be statistically significant (alpha <0.05) with high statistical power (1-beta=...
0
votes
1
answer
439
views
Weights vs weights in ctree CART conditional tree (party::ctree)
What are "weights" and "weights" in Conditional CARTs?
I am analysing a small data set (N=70) by recursive partitioning using CARTS. Specifically, the ctree function form the party ...
0
votes
1
answer
340
views
R: calculating approximation error of pi approximation with monte carlo
I'm new to computer simulations and R programming as a new module I had to study in college I had some issues understanding the problem asking in an exercise
The code I'm trying with :
runs <- ...
1
vote
1
answer
492
views
Is there an R function to calculate the required sample size using the Clopper-Pearson Confidence Interval?
I need to determine the appropriate sample size to estimate p in a binomial process, using R. I see the package binomSamSize, but I do not see sample size determinations using Clopper-Pearson.
1
vote
0
answers
988
views
SAS twosamplesurvival sample size question
I am trying to perform a sample size calculation in SAS for a two sample time to event case.
Here is the situation:
Assume both sample follows exponential distribution
Assume a given constant hazard ...
0
votes
0
answers
33
views
How do a select a group based on the count (minimal sample size)? [duplicate]
I was handed over a nice data set (reds) examining acorn morphology and parasites (weevils) for many trees over several years. However, the sample sizes for each tree are highly variable (5 - 75 ...
0
votes
1
answer
1k
views
Calculate sample size to mcnemar test
I want to calculate sample size by using the mcnemar test to compare 2 values of sensitivity. I am looking for the formula to implement under r for this calculation.
In this case i need to calculate ...
1
vote
2
answers
2k
views
How to compare different groups with different sample size?
I am plotting students' data from different schools to see the difference between male and female student numbers at some majors. I am using python, I already plot the data for some schools and as I ...
1
vote
0
answers
277
views
Sample size calculation for multi-level models
When using the longpower package in R for calculating statistical power and, respectiely, sample size:
How do I know which of the functions of the longpower package I should use?
Specifically, I am ...
3
votes
0
answers
1k
views
What is Keras doing if my sample size is smaller than my batch size?
fairly new to LSTM, but I already searched for a solution and could not find anything satisfying or even similar enough.
So here is my problem:
I am dealing with sleep classifaction and have ...
0
votes
1
answer
234
views
Problem with nor.test function in R. Sample size must be between 3 and 5000
I have a problem using the nor.test function as a oneway test in R.
My data contain yield value (Rdt_pied) that are grouped by treatment (Traitement). In each treatment I have between 60 and 90 values....
0
votes
1
answer
46
views
How can i draw samples increasing in size(increase is geometric in nature) from a population?
I am new to R programming and I need help with a problem. I am told that a population is normally distributed with a mean of 4 and a standard deviation of 4. The size of the population is 10000000. ...
0
votes
1
answer
273
views
A/B Test Duration & Sample Size Calculator Using pwr() Package in R
I am using the googleAnalyticsR package in R to pull some website visit stats and calculate conversion rates. No problem thus far.
However, I have become stuck when trying to calculate the required ...
0
votes
2
answers
127
views
Minimum sample size n such that difference is no more than
What is the minimum sample size n (or the length n = length(x) of the data vector x) such that the difference D = 1 - statx4(x)/statx5(x) of the functions statx4 and statx5 is no more than 1/100 i.e. ...
1
vote
0
answers
325
views
Estimate power for a smaller sample size - simr package
NB: this question has been cross-posted as this GitHub issue.
I am estimating sample size based on the data from a previous experiment that included 40 participants.
I used simr::powerCurve for ...
0
votes
0
answers
99
views
Power Calculations for 3 arm clustered randomised trial
I need to do power calculations for a 3 arm trial (to determine minimum detectable effect size, given the alpha, power, sample size etc). I found the R package Three.Arm.Trials, however I was ...
3
votes
3
answers
5k
views
SMOTE in r reducing sample size significantly
I have a data set with around 130000 records. The records divided in two class of target variable,0 & 1. 1 contains only 0.09% of total proportion.
I'm running my analysis in R-3.5.1 on Windows ...
1
vote
0
answers
181
views
MANOVA with variables from different datasets
This question was already asked on stats.stackexchange, but no one answered. Since I'm not sure which forum is the appropriate one, I post this here again with some data.
I have done experiments on ...
0
votes
0
answers
504
views
In Excel, how do I find the margin of error and confidence intervals for surveys with different sample sizes and population sizes?
I'm calculating the NPS (Net Promoter Scores) for about 50 different sessions at a recent event. Each session was attended by about 50-500 people, and the number of survey responses for each session ...
0
votes
1
answer
1k
views
Sample size calculation for mixed models - simr package
I am having a model built with nlme::lme, with only one random effect (ID) and one binary independent variable (x). I am now trying to use this model to do a sample size calculation.
Linear mixed-...
0
votes
0
answers
378
views
Power curve in ggplot prints blank plot
I would like to produce some power curves with effect size on the x axis, and power on the y axis. I am only slightly modifying the code from this source:
https://moderndata.plot.ly/power-curves-r-...
1
vote
1
answer
508
views
Multiple Comparisons Adjustment for Sample Size in R
I'm trying to compute a sample size for a study that has 5 groups. Aside from computing Cohen's f for the overall ANOVA, how can I compute a sample size for each group that adjusts for pairwise post-...
0
votes
0
answers
54
views
Storing extracted values from functions after applying down rows in R
I have a data.frame with two columns $P1 and $P2, both numeric. I'd like to run the power.prop.test in library(stats),by row, and have a third column created that prints only the $n value from the ...