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

0
votes
0answers
6 views

Interpreting LM Model Ouput

I know interpretation of model output and selection has been discussed a bunch, but I wanted to ask / better understand the question below more directly. Below is the output of a model selected using ...
0
votes
0answers
7 views

Peacock Test Implementation in R [on hold]

I have two empirical distribution (without access to the observations themselves). So, in order to see if the empirical distributions are "significantly" different, I took two large random samples ...
0
votes
0answers
5 views

How to calculate weights for a weighted ordinal regression, with > 2 possible outcomes (unbalanced)?

I'm trying to perform an ordered logistic regression with the response variable being a certain 'level' of achievement (level 1 = highest level, level 2 is one below, until level 10 - the lowest level)...
-1
votes
0answers
23 views

How can i fit the following model in R ? What am i missing?

Picture shows the regression from Daniel and Moskowitz (Momentum Crashes) Rwml is the monthly log return So the first column is clear, i got nearly the same values, at least the same magnitude. But:...
0
votes
0answers
5 views

factor analysis of mixed data - difference between quality and contribution

I started to use the R package FactoMineR to perform factor analysis of mixed data (function FAMD). Could someone please be so kind and explain the difference between quality (cos2) and contribution (...
0
votes
0answers
4 views

where to specify covariates in a linear mixed effect model

I am using lme4 to create a mixed model for my data. I am looking at the effect of land cover on soil properties at three depths, for example, carbon concentration. I have identified my fixed ...
0
votes
0answers
8 views

Interaction not significant in Cox regression model?

I ran a cox model with an interaction between two categorical variables (sex and treatment group) included like: Coxph(Surv(time, status) ~ sex*treat+age+edu, data=data) And there is no significant ...
0
votes
0answers
5 views

(plm in R) Regression Model Using Column Numbers or Generally Avoiding Manually Entering Variables? [on hold]

I'm learning R as I work through a project and I believe that there is a simpler method to do what I want than to enter every single value in the model. I am using the plm function for fixed effects ...
0
votes
0answers
13 views

Nonlinear sin model with brms

I try to fit sin function with brms using next code: ...
0
votes
0answers
6 views

Post Hoc Tests with a lm model where model assumptions are violated

I have the following data set: dependent variable is carbon levels in manure. Independent varibale is the month that the manure was collected in (12 level factor). I want to test if there is a ...
0
votes
1answer
12 views

Unexpected lme result using level-2 predictor in the random part of the model

Level-2- predictors (Z) allow for modelling the level-1 slopes. They do not vary within a level-2 unit. However, it is possible to include them in the random part, ...
0
votes
0answers
12 views

How to replicate the predict function from R in Excel given I have access to “summary” output from R

I have run a 3rd order polynomial regression in R and have run the "summary" function, but I need to be able to replicate the "predict" function in Excel. I have my current working code below. Thank ...
0
votes
0answers
6 views

Statistical significance in mutations in two groups

I'm doing an analysis examining the mutations of a set of ~3 genes in 4 different populations. For Gene 1: In Group A 33/540 have that mutation, Group B 66/100, Group C 15/213, and Group D 20/32. And ...
0
votes
0answers
5 views

about the sample size calculation of three or four groups in survival analysis

I have a question about the sample size calculation of three or four groups in survival analysis. Do you know some package in R, Stata, or other resources?
0
votes
0answers
8 views

Logistic regression weight doesn't converge [on hold]

When I put the weight on glm, using the logit regression model, R say that the algorithm did not converge, but when I take it off the model works normally. All I know is that I need to use weight, as ...
0
votes
0answers
15 views

How do I run a multiple-polynomial regression using percentile rank data? [on hold]

For each x variable, I have 500 columns of specific data where each column is the percentile rank of a given column in regards to the other 499 columns. However, since I have hundreds of x variables,...
0
votes
0answers
10 views

Fast Non-uniform DFT in R

So, if I want to compute discrete Fourier transform (DFT) in R, I can create my own functions like so: ...
0
votes
1answer
9 views

`dispersiontest()` estimates dispersion too small

I am using dispersiontest(fit, trafo=2) from the AER package in R to see if my data is overdispersed and what the dispersion parameter $\alpha$ is. Since I use <...
1
vote
0answers
14 views

Modeling repeated measure effect with linear mixed effect models (lmer) in R

this is the first time I'm posting a question here, I hope someone will read it soon :) I have the following problem: I have three groups of people (ADHD patients, ADHD patients under medication, ...
0
votes
0answers
9 views

How to test nomological validity with lavaan?

in my understanding, I need to test nomological validity with SEM. But what exactly should I look at in e.g. summary(fit1, standardized=TRUE, fit.measures=TRUE)? Code for reference: ...
0
votes
0answers
10 views

How can I obtain the cross loadings with lavaan? [on hold]

In my understanding, cross loadings can only be obtained from Structural Equation modeling (i.e. not from CFA) in lavaan. Am I correct? How should I obtain the cross loadings with lavaan? Code for ...
0
votes
0answers
24 views

Random Forest in R. Dataset not symmetrical [on hold]

I did a couple of training with RandomForest in R for a class problem (event must be 1 or 0). Dataset consists of 10.000 rows and 10 variables (more or less) and each variable is built like ...
0
votes
1answer
34 views

R Ridge Regression: Choosing best lambda

I am doing ridge regression with Mass package and stuck with the problem trying to find the best lambda. I know that it should look somehow like thi ...
0
votes
0answers
34 views

How to read the corner point in this output for answer the following questions? [on hold]

I would like some help to read the output of an analysis for a homework exercise. In the database there are data about trawl fishing, in detail in my case I need to analyze the temperature of deep and ...
0
votes
0answers
8 views

Difference between dlm and bsts

I'm working on a project which asks me to analysis the Facebook's stock price, and I have to do it the Bayesian way. This assignment doesn't have a particular goal and we are free to decide the what ...
0
votes
0answers
6 views

Modelling geographic data as supply - alternative to KDE [on hold]

I'm trying to model supply vs demand for geographic data. Originally I was using KDE to "smooth" this data out over a certain radius / bandwidth. This makes sense for some types of supply like lets ...
0
votes
0answers
6 views

How to do post-stratification weighting in sampled groups with low or zero cell populations?

Let's say you received data from a sample. You don't have information on the sample design, but you have population data so you want to employ post-stratification weights to better align the sample ...
0
votes
0answers
21 views

How do I specify a correlation matrix in univariate linear regression to account for known correlations between data points? [on hold]

I'm interested in testing whether sex differences (in birds) for a bunch of traits are explained by contemporary selection pressures on those traits. That is, for Trait(i), does the correlation ...
0
votes
0answers
7 views

Parallel analysis for principle components analysis and Multi-dimensional scaling

Does the same method for conducting a parallel analysis for principal component analyses apply to find the cut-off point for multidimensional scaling? Under the pretense that PCA and linear MDS are ...
0
votes
0answers
13 views

Bayesian ZIF negative binomial regression priors

I'm currently searching for some literature on the efficacy of various non-informative priors on zero-inflated negative binomial regression. However, most of the research I can find provides ...
1
vote
2answers
56 views

How should I account for repeated measures in a mixed effects model in R?

I'm new to linear mixed-effects models and I was wondering if I could get some help in getting my model to properly work. I have an example dataset: ...
0
votes
0answers
41 views

Percentages as both dependent and independent variables [on hold]

I need to do different types of regression: dependent variable expressed as percentage (continuous in [0;1]), independent variable is a running variable (continuous in [0;+inf[) both dependent and ...
0
votes
0answers
19 views

Simple slopes after rescaling variable

I ran a regression model with a dichotomous predictor (x) and a continuous predictor (z). Following advice here, I rescaled both regression inputs by 2 standard deviations and centered them at the ...
0
votes
0answers
16 views

Theory : possibility to get probabilities from tree methods with unbalanced data classes?

I am working with C5.0 from the C50 R package. I try to predict a binary output from severly imbalanced data classes (~ 2% of "1"). Without weighting the train variables, or adding a cost on type I /...
0
votes
0answers
6 views

is GLMER the best way to deal with a (numeric IV+ categorical IV =binary DV) dataset? how to plot? [on hold]

i have a dataset includes (1 numeric IV + 5 categorical IVs = 1 binary DV), so i used glmer in R to explore the predication effects: $model <- glmer(Y~(Xn+Xc1+Xc2+Xc3+Xc4+Xc5)^2+(1|id),data,family=...
0
votes
2answers
34 views

Mahalanobis distance - vectors orientation?

In the Mahalanobis distance there are both $(\vec{x}-\vec{y})^T$ and $(\vec{x}-\vec{y})$. Which one is a column vector and which one is row vector? I need to write this in R, so vector orientation is ...
0
votes
0answers
9 views

Heckman 2 stage with IV

I am working on a project. My main regression is as follow, $Revenue = Rated + Rated*Rating$. where $Rated$ is a binary variable representing whether a hotel has been rated on Travelocity, and $...
0
votes
0answers
12 views

Writing up findings from a summary given for a linear regression model

I am new to linear regression and came across the following paper when looking for examples to practice: https://www.maths.cam.ac.uk/sites/www.maths.cam.ac.uk/files/pre2014/postgrad/mathiii/pastpapers/...
2
votes
2answers
41 views

Selecting informative priors

I am questioning myself on how to chose the priors for a bayesian analysis in Rstudio. I'm trying to investigate the chances of relapse in a set of patients. These patients are all affected by a ...
0
votes
0answers
13 views

Inconsistency between Probability Matrix and Output for KSVM

new user here. I was working with a Kaggle gene expression dataset (https://www.kaggle.com/crawford/gene-expression) and was using a SVM to create a model. When I outputted the predictions for the ...
0
votes
1answer
20 views

Two time-varying coefficients in Kalman filter with DLM package [on hold]

I am trying to estimate a model that has two time varying coefficients in R using the "DLM" package. My measurement equation would be = Yt = F1tx1t + F2tx2t + v The state equations are: F1t = F1t-...
0
votes
1answer
28 views

Missing values in R data frame [on hold]

How does R handle missing values with respect to the context below and missing values? I'd be very grateful if anyone has a link to documentation explaining what R is doing in the below example and ...
0
votes
2answers
29 views

Repeated two way anova in R [on hold]

I would like to do a two way repeated anova in R. My data includes three species (A, B, C) subjected to three treatments (1,2,3) - there were 3 replicates of each treatment. Class data (1-5) on each ...
0
votes
1answer
12 views

Determining CausalImpact when there are 0s in the response variable

I am trying to run CausalImpact to look at the impact of an advertising campaign on customers who have shopped in a long time at the merchant in question. One of the variables I am using as a ...
0
votes
0answers
12 views

How to Interpret Confidence Intervals provided by CausalImpact

I am not sure how to interpret the confidence interval obtained when using the CausalImpact function in the CausalImpact R package. Is there a difference in interpreting the interval between the pre-...
0
votes
0answers
11 views

Computing realizations of a gaussian process in parallel

I have to evaluate many realizations of the same Gaussian process in parallel, using R. Currently, I am calling mvrnorm ...
0
votes
0answers
13 views

Between grouping-factor variance-covariance matrix

I am working with lmer in R and am unsure on the assumptions on the variance-covariance matrix for the random effects in a mixed effects model. If I have a 2 ...
1
vote
1answer
27 views

Clustering and interactions in a multilevel model in R

We are conducting an individual participant level meta-analysis on a series of clustered randomised controlled trials, where we are mainly interested in an interaction effect with a characteristic (...
0
votes
1answer
33 views

Fit and Predict Arima in R [on hold]

I am trying to fit a Arima model in R with an independent variable (ARIMAX). The model fit data contains both positive and negative numbers. The issue is that after fitting the model, the predict ...
0
votes
0answers
14 views

missing factor levels from the interaction function in R [on hold]

I wonder if anyone has already come across this and can please point me to an existing discussion / a solution of the issue. Consider these data: ...