# 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,472 questions
Filter by
Sorted by
Tagged with
1answer
28 views

### Transforming old data to “match” updated data

I have a couple of large data sets, one from an older machine and the other from a newer better version. I want to find a value that I could apply to the old data to basically have the new data's ...
1answer
59 views

### Dealing with NAs in Poisson Regression estimators [duplicate]

I am trying to fit a Poisson regression in some soccer matches. I want to be able to predict matches of the first league for a new season, which means that there will be some new teams that have been ...
1answer
55 views

### Testing the difference between two independent regression coefficients

I would like to test the difference between two independent regression coefficients. David C. Howell's book 'Statistical Methods for Psychology' (Chapter 9.11) suggests that there is a t-test for ...
2answers
33 views

### Writing the likelihood and conditional variance in a ARMAX model or regression with GARCH (R rugarch with external covariates)

I was looking at the r package called rugarch (docs) also mentioned in this question and in the Matlab Guide but I cannot see any example of how the likelihood or log-likelihood is computed when ...
0answers
13 views

### R- Auto Arima with Kalman Filter

In Python auto arima, it is clearly stated that when you set the method parameter as "ml" (maximum likelihood), residuals are obtained via the Kalman Filter. What is its equivalent in R?
1answer
20 views

### Is it valid to use Anova (in R) to compare alternative multinomial log-linear models?

I am familiar with the idea of comparing alternative linear regression models using anova(model1,model2), for models fitted using ...
1answer
45 views

### What is gained from a scale-location plot?

The plot function in R provides four diagnostic plots for linear regression: It seems like the residuals vs fitted plot and the scale-location plot are basically ...
0answers
17 views

### Practical advice for identifying important interactions terms (with glinternet, or other approaches)

I work with scientists who supply experimental data (often that doesn't come from deliberate Design of Experiments). I am comfortable addressing the question of "which predictor variables are the ...
0answers
45 views

### interpreting a violin plot [duplicate]

I made a violin plot for the first time. But I am not sure how to interpret it. I have three categories: hard, soft, and neutral and for each of the category I have a corresponding summary statistics (...
1answer
27 views

### clustering comparison

I was wondering if there is a method to compare clustering results. I initially tried to use the Rand index but my results do not satisfy the conditions to use this method. In my specific case, I ...
3answers
69 views

### Linear Model with Categorical Predictor Variable: What's the Math behind it?

I do understand how linear regression models work with numerical data (finding the line that has the least squares). Having read Grolemund's and Wickham's R for Data Science, I was wondering about one ...
0answers
20 views

### Multilevel regression meta-analysis : no existing package? (Edited)

The question is in the title. Meta-analysis with binomial distribution I'm trying to do a meta-analysis on occurence of an event across different studies. For each study $i$ ($i=1,\dots,N$), I have ...
1answer
37 views

### How to simulate non-linear regression model with splines?

I want to simulate a non linear regression model of the type $$y_i = 1 + x_i + bs(x_i)+ e_i,$$ $i=1,...,1000$, where $bs(x_i)$ is a b-spline. I have tried to use the ...
1answer
41 views

### Handling linear dependence among (non-mutually exclusive) binary predictors in linear regression

I have a number of movies tagged with varying genres. ...
1answer
41 views

### Combine multiple rows into one row in R [closed]

I am creating a sample of 3 observations with 3 values. I would like to then combine them into one observation and determine the frequency of duplicate values but would like to know what values are ...
1answer
20 views

### Range of Values for Random Forest Mean Decrease in Accuracy

When calculating variable importance using the unscaled (Scale= FALSE) permutation variable importance, what is the range of values you can get? Is it expressed as a percent (e.g. a value of 0.1 ...
0answers
12 views

### How can i tell, that the differences in my regression is significant?

I regressed the return of my trading strategy on: the market return (Uncond beta) reg<-lm(Market.opt$WML~Market.opt$Mkt) the subset of my sample, where ...
1answer
55 views

### Expected number of zeros in multinomial vector

When $X=(X_1,X_2,\ldots,X_K)$ follows a multinomial distribution with the size parameter $N$ and probability vector $p=(p_1,p_2,\ldots,p_K)$, what is the expected number of zero outcomes in $X$? In <...
0answers
19 views

### Weighted Seemingly Unrelated Regression in R

I am using the systemfit package in R to estimate a system of three equations using the seemingly unrelated regression approahk ...
1answer
30 views

### Variance of mean of correlated variables

Page 228 of THIS BOOK provides the formula for the variance of the mean of more than two correlated random variables: where $m$ is the number of variables, $r$ is the correlation between the ...
1answer
22 views

### Comparing residual deviance to null deviance in a logistic regression model: Is percentage reduction fallacious?

If I run a logistic regression model in R...for example summary(glm(data, formula = dichotomous.outcome.variable ~ age + hpv,family = binomial(link = "logit"))) ...
1answer
181 views

### Can I ignore the negative R-squared value when I am using instrumental variable regression?

I am running an instrumental variable regression using 'ivreg' command in R program. I find that all my validity tests related to endogeneity are satisfied only except the R-squared value which is ...
1answer
28 views

### Interpreting Fisher's test and power analysis in R

Currently I want to check whether there is a significant difference between the data from two clusters with n1 = n2 = 6. ...
0answers
14 views

### Determine validity and relability of Feature importance

I am looking for a method to determine the validity and reliability of the feature importance for a regression. I can determine the reliability and validity of the overall fit using the RMSE. A low ...
0answers
13 views

### How to plot the ARIMA fitted values of a time series in R?

I'm currently analyzing the stock market price indices for my undergrad research. Namely, ASPI: all share price index(abbrv:aspi) & SL S&P 20 (abbrv :std) auto.arima() gives me the following ...
0answers
31 views

### Compare coefficients from different regression equations in R

I am trying to compare differences between coefficients in different regression equations. Specifically, I have 2 regressions looking at the effect of Importance to Donate on Guilt, Feeling, and ...
1answer
48 views

### Parameter Updates in Stan

I am working on an example in which I have obtained parameter estimates using Stan. In a real life scenario, I would receive more data every week. The data are covariates of a product which are used ...
1answer
9 views

### Instrumental variable totally changed the endogenous variables's coefficient

I have a set of panel data and I am adding one instrumental variable to the panel regression. The coefficient for the endogenous variable is -3.8% (p<0.0001) with R^2=20% but after adding the IV ...
1answer
42 views

### Compare clusters quality (internal validity) after and before dimensionality reduction by PCA

I've asked this question a few days ago Evaluating HCPC clusters using cluster.stats from fpc library because I was trying to evaluate the quality of my clusters after I did dimensionality reduction ...
0answers
36 views

### How to plot estimate + raw data of a Bayesian zero inflated poisson?

GENERAL QUESTION: How to back-transform estimates from a zero-inflated poisson to obtain the original scale in R? (I tried exponential like for poisson but the results are wrong) DETAILED ...
0answers
25 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 ...
2answers
23 views

### 3 replicates per modality - Anova possible?

It seems like a basic questions, but I found so many answers on the internet... I have an experiment in which I observe 3 plants per modality. I have 6 different treatments; All the conditions are ...
1answer
23 views

### Using a AIC ot LRT for a GLM and LMM

I am trying to compare 2 models (a GLMER with a random effect and a GLM with the random effect removed). However, I was told you can't use an AIC for GLM's but I thought you could!?
2answers
51 views

### Principle Component Analysis on categorical predictors [duplicate]

I tried running prcomp() on my training set, which contains some categorical/factor predictors (as well as a binary response), and was given an error saying my data needs to be numeric. Can PCA not be ...
0answers
28 views

### Test to compare difference in location estimates between sex

I have geolocation data for the locations of ~20 animals. I want to know if there is a sex-specific difference (female orange), but geolocation data is very broad scale i.e. M Long: -11, Lat: 8 F ...
2answers
69 views

### Calculate the intercept from lm

I would like to understand how I can compute by hand the intercept from lm. The following example is a fractional factorial design (3^3) and the variables are factors. ...
1answer
61 views

### Predict the price of single part after running the ML algorithm

I am working on a problem to predict the price of a mechanical part. I collected all the necessary data and variables.($1200 \times 25$) I have build multiple models using $log$ transformations of ...
2answers
27 views

### Does rowwise distribution of random values in creating a normally distributed vector variable in matrix(rnorm(.), byrow=TRUE) damage normality?

(Reprodicible example added) 150-character-limitless full question is: Does the rowwise distribution of values in creating a normally distributed vector variable via ...
3answers
99 views

### how can I calculate confidence interval with small sample in R?

I have 50 observations, and I can get a mean and standard deviation values. In this situation, how can I get a 95% confidence interval in R? using bootstrapping? 0.594697 0.7976501 0.7355372 0.62818 ...
0answers
23 views

### How to calculate risk ratio for chemical substances

Simple example: Three different chemical substances are given to patients (each to 5 patients). Some patients die, some not. Samples (number of patients) are not equal. How to calculate the rate of ...
0answers
26 views

### How to use Hidden Markov Model for predicting the last state in set of sequences? [duplicate]

I have a dataset consisting of a set of sequences as follows: ...
0answers
10 views

### Null and Residual deviance [duplicate]

I am running a glm family = poisson for count data. I am not really sure how to interpret my null and residual deviance and haven't found anything else useful to help explain how to actually ...
0answers
22 views

### What are the options to cross-validate imputed data generated with the MICE package?

I am currently imputing missing values in a dataset with the help of the MICE package. The dataset contains different types of variables (binary , continous numerical and ordinal variables). The code ...
0answers
30 views

### Forecasting time series for categorical variables

I have time-series data with daily sales for shops and sold items. I would like to predict the number of each product sold in each store. What is the best way to solve this problem? It is necessary to ...
0answers
30 views

### GLM Logistic regression in R: one category is significant, but others are not. Should I drop the variable? [duplicate]

so I am using GLM for logistic regression in R and I have some variables with many factors. I ran the model and has the result like this: My question is: 1. Is this variable significant? ...
1answer
29 views

### High GLMER dispersion parameters

I am running a glmer with a random effect for count data (x) and two categorical variables (y and ...
1answer
104 views

### Do regression results change depending on whether a certain variable was manipulated within-subjects or between-subjects?

I was taught in my statistics classes that whether a variable was varied between-subjects and within-subjects made a difference in the results of significance tests. For example, with t-tests, all ...
0answers
44 views

### Weibull Model in Stata vs R

I am currently trying to replicate a study on war duration, which used Stata's streg function to estimate a parametric Weibull model. The stata code reads: ...
0answers
23 views

### Building a heatmap from value ranges for variables used in an equation

I’m trying to create a heatmap showing the variable L along the variable nA on the x-axis and the variable ...
0answers
14 views

### Bernoulli Cusum Chart?

Can I use the R package named 'cusum' to make bernoulli cusum charts or should I use another package? I've been asked to explore using Bernoulli cusum chart for trending a parameter that's usually 0 ...