# 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.

25,063 questions
Filter by
Sorted by
Tagged with
0answers
5 views

### Interpreting ACF and PACF plots

In the first link, I have a plot of the time series as well as its associated ACF plot. I noticed that the ACF was slow to die down, indicating non-stationarity, it also exhibited some cyclical nature ...
0answers
5 views

### Which test to use for randomness in R?

I am trying to check the daily absence of our teachers in the school during the last month. The data I collected is: ...
0answers
11 views

### How to find a virulence factor?

I have a big data set of protein expression. I just put the head of it. ...
1answer
13 views

### Applying Fixed Effects in a Difference-In-Differences Estimation using Least Square Dummy Variable Approach in R

I am trying to do a Difference-In-Differences Regression with Fixed Effects. The regression is meant to estimate the impact of participating in a televised Sports Event on the Social Media Follower ...
0answers
9 views

### Which is the best way to run a two way repeated measures anova in R

I have run a repeated measures anova with two IVs (score 1-7) and a DV (score 1-7). These are my options so far: aov(dv ~ iv1*iv2 + Error(id/(iv1*iv2)),data = df) ...
0answers
19 views

### Which type of sums of squares does lm-function in R use?

I ran a two-way ANCOVA in R: ancova = lm(DV ~ IV1*IV2 + CV1 + CV2 + CV3, data = Data) summary.aov(ancova) Anybody know if this uses type III sums of squares? I ...
0answers
8 views

### Can someone help me understand the random effect parameters in my linear mixed model output?

I have some data for which I modeled in a linear mixed model. I understand everything except the random effect parameters. These variance parameters appear to be bound between -1 and +1. How do I ...
0answers
6 views

### How do I add an interaction term to MANOVA in R?

I would like to compute Pillai's Trace from multivariate analyses in R on an interaction term. A subset of my data is: ...
1answer
7 views

### Coding Nested Effect in gam() via Implicit Nesting

I'm trying to find the best specification of a nested mixed effects model using gam. I don't have an easy dataset to share, but simulate an example below - and have figure to help explain. Basically, ...
0answers
14 views

### Interpreting the following multiple linear regression model

I'm having difficulties trying to interpret the coefficients of my linear model. Background: lm(encounter_rates ~ year + pland_changes + regions) I've run a ...
0answers
5 views

### numerical response variable and categorical explanatory variable How to transform the response data to normal distributed [closed]

I wish to use normal distributed data to do the ANOVA test but it is not very common to transform response variable directly and it doesn't make sense to transform the categorical variable as well. ...
0answers
11 views

### How to interpret the marginal effects (MEM) of binary variables in R?

My model is binary logit regression and the dependent variable is default (whether a loan would be defaulted, if it was, it is given a value of 1). I ran logitmfx (...
0answers
12 views

### implement Big M method in r language without using any package [closed]

I want to implement Big M method in r language without using any package. And provide runnable codes. User will be able to enter values.
0answers
25 views

### Can I always defend using ols, (for example when my dependent variable is ordinal), if I satisfy all CLM assumptions?

Previous reading Let me first say that I went through this post: (How to determine which distribution fits my data best?) and this post: Assumptions of linear models and what to do if the residuals ...
0answers
6 views

### Suitable sequence prediction model in R (many-to-one)

I have data collected over a certain number of patients denoting the ordered appearance of the symptoms of a certain disease, as sequences. The data are like: Patient1: B>C>CS>CD Patient2: B&...
0answers
10 views

### Are FDR corrections necessary in this case?

Good day everyone! I am very new at running stats analysis and I haven't quite been able to grasp the concept of FDR corrections quite well. Currently, I am running an analysis with three goals: ...
0answers
3 views

### Issue with 'varying arguments not being the same length when converting data format - cannot detect cause of issue [migrated]

I am looking to run a multinomial logit model on discrete choice survey data. Prior to doing this I want to have data in wide format in my csv doc in excel and convert to long format in R using the ...
1answer
25 views

### Multiple regression models in R [closed]

If I have data that include: The gender variable gets the value "1" for a woman and "0" for a man. The variable hours is the average number Of weekly working hours The variable ...
2answers
29 views

### R's lm(), get x when y is known [duplicate]

Here is some data and a logarithmic model: df <- data.frame( x = 1:8, y = c(7.5,6,5.2,4.3,3.9,3.4,3.1,2.9) ) model <- lm(y ~ log(x), data = df) I am ...
1answer
13 views

### Find x-axis value given a tail probability of an custom PDF estimated using approxfun(density()) in r

I know qnorm() function returns the z-statistic of the applicable normal distribution that corresponds to a given probability (see example below). ...
1answer
19 views

### Remove Interaction term with Factor values in R

I have following model: ...
0answers
4 views

### Weights in Caret train

I would like to know more on the weights parameter in Caret train as I could not find any thing concrete from Caret documentation. Whether the weight indicates cost sensitive learning by engaging ...
0answers
5 views

### What is the correct way to specify error terms and fixed effects vs random effects in an anova in R?

I am very new to coding and stats in general, so please let me know if I am making any big mistakes here. I am writing code to analyze the following data: ...
1answer
8 views

### Interpretation of linear regression with covariates. Categorical variable has 3 levels

My independent variable is genotype, which has 3 levels (wild type, heterozygote and homozygote) My dependent variable is calcium concentration, which is a continuous variable. I first run a one-way ...
1answer
20 views

### How do I interpret Box-Cox-transformed linear model outputs in R? [closed]

I have a data set that was skewed, and I experimented with transformations to reduce the skew. I found a Box-Cox transformation reduced the skewness the most. It looks like this: ...
0answers
21 views

### How to model exponential time decay component with linear regression?

I was wondering if there was a way to run a regression on a formula that is not exactly a straightforward $Y=\beta X + \varepsilon$ Essentially what I have is a bunch of features $x_i$, with an ...
1answer
28 views

### Understanding the connection between binomial (logit link) and emmeans output

I ran a binomial model with a logit link in R. I am trying to understand the coefficient relation to the logit scale output provided by the emmeans package in R. Idled is the reference level for "...
0answers
10 views

### Functional time series forecasting

I am working in hourly multivariate time series forecasting, so due to big data, I made the forecasting through functional time series. The model that I am using is the functional autoregressive model ...
0answers
3 views

### How to perform a 3-way MANOVA correctly in R?

An experiment evaluated 3 factors and 3 responses to treatments. The selected factors were the chemical used (Chemical), the mixing speed (...
1answer
17 views

### Stratification McNemar Test in R

I have categorical data before and after a condition (paired data) about preferences (yes/no) and I have other variables such as sociodemographic values (sex, ethnicity, etc). What I need to know if ...
1answer
35 views

### R: “family” and “degree” specification in loess fitting

I can't understand the difference between the possible specifications of the family option in the loess command in R. This is ...
1answer
69 views

### R Confidence Intervals for quantiles from Generalized Lambda Distribution

I'd like to compute confidence intervals in R for quantiles from generalized lambda distribution. Steve Su (2009) introduces below 2 ways to calculate confidence intervals. I think I could understand ...
1answer
20 views

### Can I calculate the integral of the O ring statistic from Ripley's K function?

I need to calculate the integral of the O ring statistic, and I do not see any available package to use in Rstudio that can provide me with this value. For example, here is the O ring statistic plot ...
0answers
20 views
+50

### Correcting (or bootstrapping) the standard errrors for a two stage glm

Cross posted on StackOverflow I want to somehow correct the standard errors of my two stage residual inclusion, where in contrast to the 2SLS, the residuals are included in addition to the ...
0answers
5 views

### ICC for cluster within cluster (survey package R)

So I'm not quite sure about the terminology but what ever it's called the actual scenario is straight-forward. I'm dealing with a two-stage cluster sample. It's also stratified but let's set that to ...
0answers
7 views

### prediction of lme object does not show all the range in predictor variable

I am trying to plot the fitting line associated to a fixed effect in an lme object, using the base package. For that, i am using (this dataset) And this code: ...
1answer
25 views

### Hypothesis testing with time autocorrelated data

I have a dataset such as the following: ...
0answers
17 views

### What correlation a multilevel model accounts for? (R code provided)

My basic understanding of a multi-level model is that by adding a grouping variable (i.e., a level), we can generally account for correlations (dependence) between ...
1answer
26 views

### GLM weights vs. identical observations

I was recently working on a homework assignment on binary GLMs and the following question came up when comparing solutions with a classmate. The data for the problem was given as a contingency table, ...
0answers
8 views

### Missing Hayes Moderated (2) Serial Mediation (2) Model?

I have Hayes' "Methodology in the Social Sciences - Introduction to Mediation, Moderation, and Conditional Process Analysis A Regression-Based Approach (2018, Guilford Publications)" and ...
0answers
8 views

### Is there a way to graph an interaction from a mixed effects model with covariates?

I am trying to graph the results of a week by condition interaction in a mixed-effects model with multiple covariates. Data is nested within-subject. I am predicting steps by week (factor with 5 ...
1answer
60 views

### EM algorithm for normal mixtures with constraints

I have $G$ groups, each with $N_g$ data points $y_{ig}$, $g=1,\dots,G$ and $i = 1, \dots, N_g$. The group for each data point in observable. I want to estimate the normal mixtures model with $K$ ...
1answer
41 views
+50

### How to get residuals from an ordinal logit/probit, and which ones to get

I stumbled upon this question on Stack, where someone asked how to get the residuals from a polr regression, to which Ben Bolker answers as follows: My question ...
1answer
15 views

### If data is square rooted to assume normality, should the data used to test with Levene's Test for Equality of Variance also be square rooted?

I am going to run a MANOVA, two of the assumptions are normally distributed data and equal variances. I had a data set that non-normally distributed. I square rooted it, and it is approximately ...
0answers
11 views

### Differences between pairs of mean. SED and LSD confidence intervals

I have a Anova related question and would really appreciate some help. I am trying to creat a table with: The estimate differences between means, Standard error of the differences (SED), and the 95% ...
1answer
28 views

### Are the important factors given by gradient boost more arbitrary compared to random forest

I compared the output from the two approaches using rfsrc() and gbm() in R respectively. The important factors given in the output from the two approaches are totally different. Since the importance ...
0answers
13 views

### How to set up the matrix in data generation in R? [duplicate]

I am trying to generate two continuous predictors and one continuous outcome from mvrnorm. This is my R code. ...
0answers
14 views

### Sample size calculation for comparison of 3 groups

I need to calculate the sample size needed. The outcome variable is binary (0 if no, 1 if yes). I have three groups (e.g., group A, group B, group C). What I know (or assume) is that the proportions ...
1answer
23 views

### auto.arima - What am I doing wrong?

I am using auto.arima to do a forecast of a series but I am getting really poor results. I think that I am doing something wrong when writing my code. I use 120 observations as my training data to ...
0answers
25 views

### What is the recommend function for Ridge regression [duplicate]

The following question is an answer for why lm.ridge and glmnet results are different and how to solve that. My question is ...