The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [r]

Use this tag for any *on-topic* question that (a) involves R either as a critical part of the question or expected answer, & (b) is not *just* about how to use R.

20,788 questions
Filter by
Sorted by
Tagged with
6 views

R: Power analysis for a 2 by 2 within-within ANOVA interaction effect [pwr::pwr.f2.test()]

Background I would like to perform a power analysis for the interaction effect in a 2 by 2 within-within ANOVA design. I would like to crosscheck that I am performing this correctly using the ...
8 views

Problems with using many binary variables in regression

I am curious about a possible regression model I want to run. Let's say the model has a (Yes/No) response and several binary independent variables. The independent binary variables are taken from ...
5 views

Imputation in Time Series with Varying Start Dates

I have a set of time series variables, most of which start at the same time as my dependent variable, but some of which are missing at the beginning of the series (at start at varying dates). I want ...
9 views

Random Forest Classification [on hold]

I am trying to make random forest classification but anyway it is doing regression, I can not change it ...
18 views

R: Simulate linear mixed model with matrix algebra

I am trying to learn how to simulate LMM data with matrix linear algebra. So far I've managed to simulate a simple model with a random intercept: ...
11 views

R: Accuracy Sensitivity/Specificity [on hold]

I want to use Accuracy in a Multiple-Choice Test as my Dependent Variable. I have questions with 6 possible answers, 1 answer is always correct. I have 3 columns: Response, Right Response, Accuracy <...
19 views

18 views

How to handle missing values in a bootstrap resampling distribution?

I am creating a function that calculates point and interval estimates for a statistic of interest. I get the interval estimate through bootstrapping. However, it occasionally occurs that the statistic ...
35 views

How to use a custom method in ggplot2 for fitting smooth line [on hold]

In normal cases we would have something that resembles ggplot(data=data.frame)+ geom_point(...)+ geom_smooth(...,method="lm") However, I do not want to fit a ...
14 views

How to adjust data labels to alluvium instead of axis for bump time series chart (R ggalluvial)? [on hold]

How can the data labels in this example be made to appear centered on the alluvia?: ...
7 views

Rstudio Odds Ratio Test Change Order [on hold]

I am trying to get 95% interval lower limit and upper limit. I know that the order and orientation is important for the odds ratio test. This is what I wrote on Rstudio. Everything looks good, ...
16 views

MLE for bivariate normal data with known error variances

I am working with a set of bivariate data arranged into columns labelled 'x' and 'y'. I also have measurements for the error variances corresponding to each observation, labelled 'sx' and 'sy'. An ...
16 views

How to extract predicted probabilities from glmer results for a logistic mixed effects model [on hold]

I have two groups that I follow over 4 time points (Baseline, Three months, Six months, and Year). The outcome is some binary variable, lets say presence or absence of cancer. ...
29 views

Regression analysis not showing the first level of treatments

I have my data that looks like this: data: or in R: ...
15 views

Meaning of Power Analysis function parameters for SSizeLogisticBin when A/B test in R

I did recently an A/B testing course in R from DataCamp and I could not understand the parameter B from the following function from the package powerMediation ...
18 views

Glmnet() returns different coefficients [on hold]

I want to get the regression weights from glmnet(). However, I get different coefficients with different methods. ...
7 views

autocorrelation graph in python like R (for two or more series)

In R one can call the acf function on a bivariate (or higher dimensional multivariate time series) and it will output all the self and cross correlations (for example with a bivariate series the ...
5 views

GEV distribution: nonstationary location sign changes when adding nonstationary scale parameter in MLE

I am trying to estimate the location, scale and shape for a nonstationary GEV distribution with block maxima. HRindex is the yearly maximum daily rainfall. I used following code in R to achieve ...
7 views

Interpretation of linear, quadratic, cubic outputs of ordinal predictors in glm calculation

I have a binary dependent variable, and some numeric, binary, and ordinal independent variables. The whole idea is to create a predictive model based on all these data, which can be reported to others,...
7 views

R - pglm - panel logistic regression - R-squared and fixed effects

I am running a panel logistic regression using the pglm package: ...
14 views

Predicting multiclass outcome using R

The dataset contains about 17000 observations, the outcome variable (with about 10 classes) and the predictors (about 10) are all categorical variables. Which algorithm is the best to employ to train ...
7 views

comma format using grid.draw to build a table [on hold]

For obvious reasons I am still using gridExtra 0.9.1 for my reports. Consider the small dataframe below. I am trying to format the columns with commas but the format inside grid.draw is giving the ...
11 views

Using S statistic in place of Cohen's Kappa: R code provided [on hold]

This article proposes a new statistic called $S$ statistic to replace Cohen's Kappa for inter-rater agreement using categorical data. I know I can compute KAPPA for each category using the ...
14 views

Correct Estimator for Path Analysis/SEM Using Categorical Covariate

I'm currently building a path analysis model with model-based corrections for measurement error, using a latent variable structural equation model (i.e., each observed variable serves as a single ...
16 views

Which statistical studies should be carried out for expression analysis of genes when I have fold change data of genes

I am new to R and data analysis. I am working on gene expression. My data frame contains Gene_ID and quantification_value which is the fold change of the gene. ( the value represents the amount by ...
27 views

Regression analysis with multiple categories

I have this data below which I am analyzing using R. First, I am trying to find which predictors (chem1, chem2 and chem3) have effects on yield for this data. I did this model test below and found ...
30 views

Matching vs simple regression for causal inference?

This is a really simple, newbie question. I am really confused about the notion of matching and when it can be used instead of a multiple regression? Assume I have listed all the confounding ...
14 views

What is an example to show Wald's test does not confirm significance at the same level for each variable?

Suppose that the true model is given by Y=0.3+X1+X2+X3. Assume we have 100 training examples where each covariate vector (X1, X2, X3) is randomly drawn from some distribution P and Y is generated ...
24 views

How does BATS model work?

I am using BATS on a univariate time series model. I have observed strange behaviour. I have data from 2016 to till date (weekly level). If actual are considered from 2016 to 2019 May, I have used ...
32 views

Interpretation of zero-one-inflated beta models in brms

I have 20 participants who have watched 18 clips. Every clip belongs to one category of pleasure (p_cat: negative, neutral, positive) and one category of intensity (i_cat: low, medium, high). I have 2 ...
15 views

Error in R code : object of type 'closure' is not subsettable, (not a “data”) issue…I think [on hold]

I'm trying to run a function for the epanechnikov regression estimator and I've run into this error message only when attempting to Knit the markdown file: Error in ddd[, iv.name] : object of type '...
18 views

...
9 views

Using count (instead of proportion) data with cbind() in R… in both dependent and independent variables?

In a study I hypothetically conducted, I have the number of times individuals pressed an "A" button and the number of times they pressed a "B" button. I also recorded the numbers of times they made ...
14 views

Dynamically updating posterior density in R

I want to redefine my function in a loop by calling the function from last iteration. However I know this is basically a recursive way which I don't want. To give an example, see the following ...
27 views

Simulate cointegrated prices and VAR model [on hold]

I am trying to simulate cointegrated stock prices and use a VAR Model to make forecasts. This is the code I wrote so far: ...
13 views

How to interpret the results of a loglin/loglm model?

i've been working with a dataset of the following form: ...
81 views

How to understand carry out the “score bootstrap”? [on hold]

I want to translate the "score bootstrap" that Kline and Santos (2011) propose into R code. The algorithm is described on page 6 as follows. STEP 1: Obtain the full sample OLS estimate $\hat\beta$ ...
19 views

How to compare a model with my data [on hold]

using R I have to compare a model, that is the Fitt's law, with my data. In particular the Fitt's law states that MT = a + b × log2(2D/W), with MT is the time needed to perform a task, a and b being ...
16 views

Using garchFit to fit an ARCH(1) process

I tried using the garchFit function FinTs library. This is what I am trying to run: garchFit(formula=~arma(0,1,2)+garch(0,1), data\$1 YR) However I get the ...
9 views

plot fuzzy_partitions in R [on hold]

I am trying to fuzzify a distance measure of a point using only fuzzy_partitions. I do not need a full fuzzy inference engine as all what I do need to aobtain is the corresponding fuzzy membership ...
27 views

How can I generate a completely balanced combination

Attaching a code that generates unique combinations of 8 letters but, it still lacks a condition wherein all letters should have equal counts per column. For my code, basically, letter a to h should ...
77 views

How does random variable nesting in GAMs work (mgcv)?

Consider me very new to the world of GAMs, I am actually using it out of necessity rather than by choice but I thought it could be a chance to learn something new anyway. Originally I had hoped to ...
31 views

What is the difference between multiple regression WITH interaction, and WITHOUT interaction? (* vs + vs " vs : in lm)

I am attempting to set up a multiple regression model using "lm", but I am unsure whether to use :, + or * to indicate the interaction between multiple predictor variables. ?lm shows the following ...
13 views

Correlation between two variables from nested, non-normally distributed, semi-continous / count data

I am interested in correlating the physical distribution of cell types and cellular material within tissue that has been imaged as a large grid of images (each grid is a datapoint). My data comprises ...
27 views

R code of t-test with 1% level of significance? [closed]

The manufacturer of a certain make of electric bulbs claims that his bulbs have a mean life of 25 months with a standard deviation of 5 months. Random samples of 6 such bulbs have the following values:...