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

Filter by
Sorted by
Tagged with
1
vote
0answers
19 views

Converting data from exponential model to a linear model

This question came up recently and I am really struggling to understand how to even do this. I have just started learning statistics and would like is someone could show me how this could be done in R....
0
votes
0answers
8 views

Classification of a data sets into groups using independent categorical variables in R or Rstudio [closed]

How can a classification of data sets be done into two groups (male group and female group) using independent categorical variables (for example qualitative feature of a human face) in R or Rstudio?
0
votes
0answers
20 views

Can PCA prediction guess the group of the new data numerically

I'm wondering if there's a way to supply new data to a PCA prediction and have it "guess" which group the new data belongs to. In a case like the circled area in this image there are two species ...
0
votes
0answers
17 views

Multiple Comparisons Test [closed]

I´m trying to perform multiple comparison test between this paired data, but I got the following error: ...
2
votes
0answers
23 views

Wild cluster bootstrap after linear model with multiple fixed effects

I am running a linear model with multiple fixed effects. I suspect that there is spatial correlation in my data so I cluster the SEs (46 clusters). But I am worried that the standard errors generated ...
0
votes
0answers
41 views

How to calculate coverage probability from binomial confidence intervals?

For a given alpha I have been calculating various confidence intervals for a binomial distribution(Wald, Wilson, Agrest-Coulla etc.): ...
1
vote
0answers
8 views

Confidence intervals cross exponential regression when predictors scaled across zero but not when positive

I'm running non-linear regression analyses in R using the nls() function, and I've noticed some strange behavior with a particular analysis. If the independent variables contain both positive and ...
0
votes
1answer
18 views

Should I Include 'Year' Column in PCA

I want to do dimensionality reduction on a dataset. One of the columns present is the Year and the values are 2000, up to 2015. When doing PCA, do you treat this column as a factor or as numeric?
0
votes
0answers
18 views

How to group factor levels for stepwise regression using caret

Using the train() function from caret in R, I'm trying to run a stepwise ANCOVA, but each level of my 9-level factor is being ...
1
vote
0answers
35 views

Measuring Pareto like metrics for series or dataset [closed]

Pareto rule states that 20% of records accounts for 80% of total. Actually it's just a special case for a certain dataset. If we use a series: from 1 to 10 we can easily see that Pareto rule ...
1
vote
0answers
37 views

Is there a multiple pairwise sign test?

I have data that are not normally distributed (the paired differences). I want a pairwise statistical test to find the differences between the three groups only (because I have 11 groups). Pairwise ...
0
votes
0answers
19 views

volatility and conditional correlation O-GARCH

Doing an assignment i have to compare the volatility and conditional correlation of two type of O-GARCH: in the first one is standard O-GARCH while the second is an O-GARCH with principal component ...
0
votes
0answers
15 views

Is normality test required for original data prior to the principal component analysis? [duplicate]

for (i in 1:10){ qqnorm(df[, i], xlab='Quantiles of Standard Normal Distribution', ylab=colnames(df)[i]) } Most of variables are not satisfying the assumption of ...
0
votes
1answer
31 views

How to simulate forecast error when then the distribution of error is not normal?

I am using a regression model that produces non-normal forecast errors. To produce different scenarios, I need to simulate the model error, I can bootstrap from historical errors, however, because the ...
1
vote
0answers
23 views

Types of Covariates Permitted in Negative Binomial Regression

To the best of my knowledge, the dependent variable (outcome) in a negative binomial regression should ideally represent count data. In R, if the interest is to model rates, I understand the use of <...
1
vote
2answers
84 views

What is the difference between region, year and region-year fixed effects?

I found a paper on the effects of immigration on house prices, it uses fixed effects as a model. When looking at the results I found that the models use region fixed effects while some use year fixed ...
0
votes
1answer
40 views

model selection for Mixed Poisson model for replicated point pattern analysis

I have fitted a mixed Poisson Point Process Model to Several Point Patterns using the mppm function from the R package spatstat. ...
0
votes
0answers
25 views

Trouble getting hurdle model to converge for continuous zero inflated data

I'm trying to fit a generalized mixed effect model for zero inflated semi-continuous data in R using the GLMMadaptive package. I have 13 variables but even just ...
2
votes
1answer
22 views

item response theory - criteria for selecting items

I'm trying to use IRT to select the best items for a one-factor scale that has 20 items. I was wondering what I need to be looking at if I wanted to select 5 or so items from these items (for a short ...
1
vote
0answers
13 views

Robustness checks for fixed effects model

So I'm estimating a fixed effects model using plm that looks at the effects of immigrants on house prices in different districts over several years. And I was ...
1
vote
0answers
13 views

How to (easily) calculate confidence & prediction intervals AFTER a model selection procedure?

First of all, this question refers mostly to linear regression. When someone uses a model selection procedure, for example, choosing the optimal dimensionality of the predictor space via best subset ...
1
vote
0answers
33 views

Understanding the output from the Johansen Cointegration test in R

I have a VECM model that Im using to determine the revenues for a firm, based on factors like Interest rates, S&P 500 and company specific variables, as follows: Stage 1: $$z_t= a+ bX_t+e_t$$ ...
1
vote
0answers
25 views

Controlling variance manually for a latent factor w/ only one manifest indicator using lavaan in R

Using lavaan in R, I'm trying to reproduce a CFA/SEM model from a publication (cf. Figure 1 of https://onlinelibrary.wiley.com/doi/pdf/10.1111/desc.12202). Below is the correlation table and std. dev....
2
votes
0answers
18 views

Why does model selection (AIC and LOO) outcomes differ between ML and bayesian approaches

I am interested in understanding whether my continuous data (dput code at bottom for reproducibility) are fit better by a linear model (Gaussian distribution) or a gamma distributed model. I ...
2
votes
0answers
37 views

Controlling for time with cubic splines in mixed model in R

My aim is to investigate the effect of a change in legislation on behavior in different countries that was measured yearly. All countries of interest adapted the same legislation at different points ...
1
vote
0answers
13 views

Interpreting slopes for individual cases in a generalized linear mixed-effects model

Similar to a previous poster (Extracting slopes for cases from a mixed effects model (lme4)), I am interested in extracting slopes for individual cases (individuals) using a mixed-effects model (lme4 ...
2
votes
0answers
19 views

Calculating 95% confidence Interval, without R

For my exam we are given extracts of data from R, usually with a summary and ANOVA table. From there a question that often comes up is to calculate a 95% confidence interval for a given variable. I ...
1
vote
0answers
18 views

How to calculate variable importance for different models? is varImp() the solution?

I'm using caret's train() function for a binary classification outcome with different models (nb, knn, lda, qda, glm, rpart, rf). I'm using varImp() and plots to determine the importance of every ...
0
votes
1answer
21 views

VIF - Muticollinearity - while using interaction terms in 'lm' method

I am currently running a linear model with interaction terms, all variables are continuous. lm (y ~ x1 + x2 + x1:x2) While I am running the VIF, I am getting very high VIF (>50). However without ...
0
votes
1answer
12 views

Importance value (with varImp from carret package) for one of the two numerical predictors has value 100, how do I interpret this?

I'm using two numerical predictors to find an outcome, when using varImp (from the carret package) one of the predictors has 100 importance and the other 0. How should I interpret this?
1
vote
0answers
12 views

Why do heteroscedasticity-robust standard errors in logistic regression?

I am following a course on R. At the moment, we are working with logistic regression. The basic form we are taught is this one: ...
0
votes
0answers
13 views

How to interpret Hosmer and Lemeshow test in R?

I'm reading some researches about how to use Hosmer-Lemeshow Goodness of Fit (GOF) Test in R. The results are quite clear and reasonable: X-squared, Degree of Freedom, p-value,.. However when I take a ...
0
votes
0answers
9 views

Argument of length 0 error [migrated]

I have two data frames (eeg and p1_1_a). They look like this: ...
0
votes
1answer
54 views

Algorithm did not converge - Multinomial mixed model (mblogit)

I'm trying to fit a multinomial mixed model with the mclogit package (using the mblogit function). But, as I adjusted the model, I'm receiving the following message and I could't find any info about ...
0
votes
0answers
27 views

Outputs of R package MDPtoolbox's `mdp_value_iteration` function [migrated]

I create a random MDP and solve it using the MDPtoolbox package: ...
-1
votes
1answer
15 views

Referencing a list item in a list in R [closed]

I am trying to get a value from a list in a list. I want to use square brackets for indexing instead of $ so that I can use variable names in a loop. However, I run into an issue. Please consider the ...
0
votes
0answers
12 views

How to fit a time-delay variable to data in R?

I have two datasets that are known (or suspected) to be a similar shape, but with the second dataset delayed by time tau and scaled by a factor mu: F(t) C(t)=mu*F(t+tau) I have data for both C(t) ...
0
votes
0answers
9 views

Assumptions when running loop for multiple regressions in R

I would like to run the same model (lm + one-way ANOVA) on hundreds of different response variables. I think I have found a way of running the model and generating the ANOVA output, but I am unsure ...
0
votes
2answers
26 views

R: Fit regression to asymptotic data

I'm trying to fit a regression to data with a decreasing exponential shape, i.e.: I have two data sets which I know should conform to this shape, shown in blue and green below: So, I'd like to fit a ...
0
votes
0answers
15 views

Clustered geospatial analysis

What's the current methodology for clustering geospatial data by features? Example: I have some demographic dataset. Let's say this contains average home price and population density. So, an example ...
0
votes
0answers
17 views

Variabile importance in cluster analysis

I need to find out which variables matter the most in a cluster analysis. I've used k-means on my dataset and, according to elbow method, I choose K = 2. Then I used a pair plot of the variables to ...
1
vote
0answers
7 views

Methods to align/reduce distance between two or more 3D graph-spaces?

I'm trying to align multiple graphs of spatial data, similar to image registration, but on a 3D graphspace of a select feature. I have a bunch of point data with x,y,z coordinates that together, ...
0
votes
0answers
17 views

Endogeneity problem with 3 variables in one model, how to solve?

I am struggling with a question concerning Endogeneity between multiple variables for my thesis, and can't seem to figure out a possible solution. I am performing panel data analysis using 3 variables:...
1
vote
0answers
15 views

Bootstrapping for missing data in a linear mixed model

I am trying to analyse data from an experiment. I would like to use a linear mixed model with either lme() from the package nlme or lmer() from lme4 in R. In my experiment subjects were randomly ...
1
vote
0answers
10 views

NA in results of nparLD package: how to get rid of it? NB. it's not a missing data issue!

We have a longitudinal pilot-study measuring “perceived manageability” via ordinal (Likert scale) data at two time points. The between-groups factor is treatment group (Group1 vs Group2; where Group1 =...
3
votes
1answer
159 views

What is the objective function to optimize in glm with gaussian and poisson family?

I am reading this post and still confused about the different ways of fitting exponential data. Specifically, why I am getting different results with following code? Could anyone help me to write down ...
1
vote
1answer
27 views

How to calculate log likelihood for gaussian mixture model

I'm trying to check the calculation of the log likelihood of a 2 component Gaussian Mixture Model using optim, but I get the wrong answer (it should return mu, sigma, alpha actual). The log ...
2
votes
1answer
24 views

Why I am getting different coefficients for R's classification model?

Dataset Consider the following dataset which measures the price of a computer given different configurations Situation After applying the four-way classification model as below, we have the ...
1
vote
0answers
10 views

Adding custom legend to fourfold() [migrated]

Does anyone know how to add custom legends to fourfold() from the vcd package? I can add to fourfoldplot() in base using the legend() function, but I want to use the custom colours for OR≈1.0 and OR≠...
1
vote
1answer
27 views

Optimize over theta or theta and beta in logistic mixed model (nagq = 0 vs nagq = 1)

I've been reading about item response model guides for R and my model is : ...