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
0
votes
0answers
4 views

How to write the R code to sample the posterior for $a$ and $\tau^2$ in the Bayesian regression?

For a simple linear regression model without intercept, that is $$y_i=ax_i+\varepsilon_i$$ where $\varepsilon_i\sim_{iid} N(0, \tau^2), i=1,2,\dots, n$ and $x_i$ is a fixed covariate. Assume that $a|\...
1
vote
1answer
9 views

Repeated measures mixed model in r

I want to compare how fast children from 2 countries [Country] run on a treadmill [Speed] at two time points [Time]. Specifically, I wanto to see whether the change over time is different in those two ...
0
votes
0answers
10 views

How to simulate data matrix filling

Suppose you can measure 3 properties $A, B, C$ for any object. However, making these measurements has a cost, so if you have, say, 100 objects, you can't fill the data matrix with 300 data points. ...
0
votes
1answer
13 views

How can I get the confidence interval of hierarchical forecasts reconciled with hts::combinef?

I have hierarchical data that I want to forecast, reconcile, and then plot each model's forecast. Using the example in the function vignette I can forecast each series in the hierarchy and plot it ...
0
votes
0answers
3 views

Adding confidence intervals to multinom predicted values plot r [migrated]

I want to create plots with predicted values and confidence intervals for my multinomial logistic models (multinom function, created with the ...
0
votes
1answer
16 views

The cumulative probability model with ordinalNet, using an elastic net penalty: more coefficients than expected equal to zero

I am trying to fit a cumulative probability model (ordinal logistic regression with 17 categories and 827 observations) with elastic net penalty using the ordinalNet...
1
vote
0answers
19 views

should I use na.omit or na.exclude in a linear model (in R)?

I try to understand the difference between using different na.actions (na.omit and na.exclude) to handle missing data in a linear model using R. I used the lm function in R (https://stat.ethz.ch/R-...
0
votes
0answers
10 views

Comparing ROCAUCs: Same Control, different Test Group - paired or unpaired? pROC

I want to compare two ROCAUCs using a bootstraping method from pROC package (roc.test). I have done a classification using Logistic Regression: 1. Cancer (high risk) vs. Control = ROCAUC 1 2. Cancer (...
0
votes
0answers
12 views

coxph function: When to use the Likelihood ratio test? [duplicate]

I'm a novice R user with only a little stats experience. I'm using the coxph function to determine the effect of a continuous variable on survival using the following code: ...
2
votes
1answer
44 views

Computing the covariance between residuals

I'm doing some self-studying of some modules about using R in linear regression. We were given data for a multiple linear model with two independent variables , $y = X\beta + \epsilon$ where $\epsilon ...
0
votes
0answers
18 views

Constraining all variances to be equal in multiple random intercepts linear models

Let the mixed model formulation be the following: outcome ~ fixed effects + (1|A) + (1|B) + (1|C) A,B and C are binary covariates. Is there a way in R (either in ...
0
votes
0answers
8 views

Bootstrap goodness of fit test kolmogorv smirnov of mixture of 3 distributions

I try to fit my dataset with GPD-Normal-GPD mixture (evmix package) in R. I'm not sure if the goodness fit test is well done by the follow script code. Can you suggest me a way to correct it. Thank ...
0
votes
0answers
10 views

moderated nonlinear factor analysis - also handles different Likert scales?

I have three datasets - one in which participants responded to the scale on a 5-point scale, two in which they did on a 7-point scale. Can I apply the MNLFA on these data? If I understood it correctly,...
0
votes
0answers
18 views

Pooled regression

I am trying to use R with some data analytics even though I am not familiar with programming at all. I am trying to run a single regression to test whether stocks' beta coefficients are different on ...
0
votes
0answers
22 views

How do I fit a distribution using fitdist if I already know the parameters? [closed]

I am fitting a Pareto distribution to some data and have already estimated the maximum likelihood estimates for the data. Now I need to create a fitdist object from it, but I am not sure how to do ...
0
votes
0answers
21 views

How to calculate significance between more than two levels of a mean cumulative function estimate in R's REDA package?

Concerning the R's REDA package: HTML Tutorial: https://cran.r-project.org/web/packages/reda/vignettes/reda-intro.html CRAN's package API documentation: https://cran.r-project.org/web/packages/reda/...
1
vote
0answers
28 views

Prior distribution for Bayesian binary logistic regression

I am still quite new to regression models, but I am trying to apply a regression model to predict victimization(0,1) in R given childhood experience. I have done many research but i still cannot find ...
1
vote
1answer
13 views

Ordinal logistic regression (polr in R): DV wrong level order

I am (trying) to conduct an ordinal logistic regression for the first time using the polr function in r. I seem to be encountering a problem with the order of my levels of my DV. My DV should have ...
1
vote
0answers
23 views

What distribution to use for left-skewed data in generalized linear mixed models (for use with structural equation modelling)?

I'm trying to run a GLMM with a response variable that is left-skewed. Eventually this model will form part of a piecewise structural equation model (using piecewiseSEM). I have data from 480 plots, ...
0
votes
0answers
4 views

calculate outliers ignoring certain columns [migrated]

I am trying to use the Routliers package to remove outliers. Here is sample data: id x y 12c 5 7 12d 2 3 I want to determine outliers for all columns ...
3
votes
3answers
341 views

Why is the p.adjusted() output multipled instead of halved?

I find it kind of hard to grasp the output of the p.adjusted() function in R, when using the bonferroni method. I understand that the Bonferroni correction actually lowers the p-value so that ...
0
votes
1answer
31 views

Alternatives of dealing with perfect collinearity in OLS Regression

I am running an OLS regression with hundreds of dummy variables. Some columns of the X matrix (design matrix) are linearly dependent on others. My question is, is the value of the fitted values (Y ...
1
vote
0answers
20 views

Am I interpreting my mixed effects Cox regression models properly? (two-level nested survival data)

I: Data structure issue (two-level nested hierarchy in survival data) [This analysis was done in R v4.0.1, using the Coxme package for mixed effects Cox regression models] I have collected data on ...
1
vote
0answers
16 views

Signal processing: How to patch over dip in signal using R?

I am a biologist starting to use R to analyze my data. Could anybody please help me solve my problem I encountered when working in signal processing in R? Problem I have a recording of a signal in a ...
3
votes
1answer
25 views

Is a Mixed Model Appropriate for Repeated Measures of Multiple Covariates?

I am doing a retrospective cohort study in which I have taken information from 4 health markers: calories, exercise time, ...
0
votes
0answers
8 views

Breusch Pagan Test for individual factors

So if I have a multiple regression model and I want to test, which factors are related to the residuals using the Breusch Pagan test. If I use the bptest() function in R by regressing the squared ...
0
votes
0answers
16 views

R package for inverse-variance weighting? [closed]

Can you recommend an R package for doing inverse-variance weighting? Yes, I could program the pointwise estimates again. And I could think about estimating the new variance of the combination, and ...
0
votes
1answer
22 views

Cross-validation using Caret in R: Why are coefficients from FinalModel identical to those from lm()?

I think I must be missing some fundamental part of the logic of cross-validation, or machine learning in general. Using the caret package in R, I ran a repeated k-...
-3
votes
0answers
21 views

How to prove if 2 data columns are independent using R [closed]

I have a data set in which i need to prove the question in the image using R. i am new to R so I do not how to do this. Please help me on where should I start and what methods i can use and any ...
0
votes
0answers
8 views

Cluster analysis in R with a mix of variable types [duplicate]

I am looking to do a cluster analysis in R with variables of mixed types (continuous, categorical). In the past I Have used SPSS's two-step cluster analysis to do this, but I need to now use R. Is ...
0
votes
0answers
14 views

Why does R throw this error when using fitdist function with nbinom? [closed]

I am trying to fit a a negative binomial function to a data set in R. I get this error and I don't know why. My data set does not contain any negative values and I assume that I am using the correct ...
0
votes
0answers
10 views

Determining autocorrelation in R

I was wondering how I could test the autocorrelation in a regression of the regressor multiplied by the error in R. So I want to test for each $x\hat{u}$ if there is autocorrelation. Usually I would ...
1
vote
0answers
28 views

Simulating Proportional Hazards Weibull model with 2 binary variables, incorrect estimation?

I am simulating survival times from a Weibull(5,3), and I also simulate 2 spurious binary covariates. When I fit a proportional hazards model with Weibull baseline, ...
7
votes
1answer
138 views

Is AIC appropriate for comparing non linear models?

In R, when trying to compare non linear models with AIC, you can use the function AIC on an nls object, which is the least ...
0
votes
0answers
17 views

How to do pairwise deletion in R studio [closed]

I'm trying to do logistic regression, but I can't seem to get the results I want. I have 6 columns of data (one dependent and 5 independent binary variables) and about 120 rows. The problem with my ...
1
vote
0answers
21 views

functional principle components is retransform to original data

I am working with multivariate time series hourly data of five years, I use the first four years as testing set and last one year as validation set. My objective is to obtain one year hourly forecast, ...
0
votes
0answers
21 views

Interpretting and Using fdrtool?

With the help of articles like this one, I am beginning to understand false discovery rate first laid out by Benjamini and Hochberg (1995). I am also seeing the value of the "unified" ...
1
vote
0answers
15 views

Two-way repeated measures ANOVA

i am a true R-dummy, however, i need to write a report for my internship. I have the following data: 5 subjects have performed 6 tests. I have observational data (ethogram, its about parrots) for 2 to ...
1
vote
0answers
31 views

Comparing logistic and Poisson regression for small event rates

I am working through the book An Introduction to Generalized Linear Models (4th Edition) by Dobson and am trying to understand question 9.7, which involves comparing Poisson and logistic regression ...
0
votes
0answers
10 views

How to compare KM curves for paired data?

How can I use stratified log-rank test to compare survival curves for paired data? I can't find any R package for this. Thank you
0
votes
0answers
7 views

Chains did not converge and mix well

I am trying to compute the parameter of copula model (Gumbel copula). I have used zero/one trick to write the copula likelihood model. The chains did not converge or mix at all. I have tried several ...
0
votes
0answers
15 views

non central chi square distribution and the non centrality parameter in R [closed]

I want to examinate the power of two sample t test in detecting a shift delta = 2 so i must generate two samples x<-rchisq(10,3) and ...
0
votes
0answers
13 views

Panel Data in R - Can I implement a plm regression with categorical data?

I am working (In R) on a panel modelling of an econometric problem. I have : one dependent variable : Y with values in real positive numbers two explanatory variables : VAR_1 (real positive), VAR_2 (...
2
votes
1answer
22 views

proper way of using “Matchit” function

I am trying to use MatchIT:: matchit function on my dataset; however, the result I get doesn't seem to be correct; thus, I started wondering if the way I used the ...
1
vote
0answers
11 views

Panel data 'binary' treatment with multiple 'odd' start and end times

I am investigating the impact of a county-level policy on crime outcomes. I am using a two-way fixed effects estimator. My exposure (i.e., treatment) is a static binary variable. The binary treatment ...
0
votes
0answers
15 views

Whitening MNIST in R

I am analyzing the famous MNIST data set with R. I have never been analyzing handwritten digit data before, so I wonder wether it makes sense to whiten the 756-dimensional data in the sense that from ...
2
votes
0answers
13 views

Which R-Squared formula is used in carets' k-fold-cross validation function

I am currently trying to implement a linear model and calculate some out-of-sample accuracy metrics while using k-fold-cross validation. I try to do this using R's caret package, so this question ...
1
vote
0answers
15 views

Minimum Sample Size for a Two Stage IPD Meta-Analysis

I am attempting to run a IPD meta-analysis and I have 12 total studies with sample sizes ranging from 3 to 40 and was wondering is there is a minimum number to conduct a two-stage IPD, specifically as ...
2
votes
0answers
30 views

Contradiction in F-test and t-test [duplicate]

I have generated a summary for a particular multiple linear regression ...
0
votes
0answers
44 views

random assignment vs. random selection (with some R code)

Question: Generally, should the random selection plan of subjects, have any bearing on the random assignment plan of subjects? Say at the random selection stage, I stratified on 3 school types (...

1
2 3 4 5
478