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
10 views

How to use CBPS in weightit [closed]

I am trying to use CBPS with weightit ...I have tried this before with sample data and gotten it to work fine but with my actual ...
0
votes
0answers
14 views

interpreting multiple logistic regression p-value when variable is not normal

I know there has been a similar question posted before Why do my p-values differ between logistic regression output, chi-squared test, and the confidence interval for the OR? but im still not sure ...
0
votes
0answers
4 views

How to adjust for confounders in multinomial logistic regression models in R?

I want to test the effect of diet intake (protein, prot, and carbohydrate, carb) on disease occurrence using Rstudio. Confounding variables are age, sex, and another variable y. ...
1
vote
1answer
16 views

Is there a name for the graphs that R's corrplot library generates?

R's corrplot library can generate some rather stimulating graphs: I have an overpowered urge to see more of these, but I cannot find there name anywhere. What are they called? "corrplot" ...
0
votes
0answers
6 views

Why do you only need to identify the first cluster level in svydesign(), even if you have multi level clustering?

Going through the a course on Survey Weights and it says that even though a dataset may sample using 3 clusters (like Counties, City Blocks, and households), you only need to specify the first level ...
0
votes
0answers
8 views

K-NN machine learning model in R - model is trained and accurate but how to use it?

For the game 'league of legends', I want to categorize observationa/matches to the label 'Lose' or 'Won'. In order to do that I make use of the k-nn machine learning model. It works as expected (see ...
0
votes
0answers
11 views

VAR restrictions on Exogenous Variables

Technically it should be possible to restrict the coefficient matrix of the exogenous variables by setting the desired restriction = 0, am I right there? If so, does anyone know how to implement that ...
0
votes
0answers
8 views

Calculate mean and standard error using bootstrap and comparing results with mean regression

I have a task and I'm not sure what I have to do in the last step. You can see task below. As I understood the task I had to calculate the mean and standard error for the dataset, then I had to apply ...
0
votes
0answers
10 views

Constrained Neural Network. Custom Loss Function in Keras in R [closed]

Good morning, working with neural network applications in the demographic field, I would like to develop an "indirect" framework to derive age-specific fertility profiles from observed or ...
1
vote
1answer
14 views

Estimating ability with IRT when item parameters are known using R package mirt

I have a paper which has utilised IRT on a revised scale of paranoia (R-GPTS). The scale comprises 10 items and there are 5 response options: In the above highlighted responses, this scores 3 / 40. ...
0
votes
0answers
2 views

measurement invariance - fixing loadings?

I have a model with which I want to test measurement invariance across gender: ...
2
votes
0answers
26 views

In R there is a problem of intercept and without intercept ,Pearson's Correlation does not follow! Why? (see the bolded resuls)

Xvec <- rnorm(200) Yvec <- 2.6*Xvec + rnorm(200) lmodxy <- lm(Xvec ~ Yvec) lmodyx <- lm(Yvec ~ Xvec) summary(lmodxy) Output ...
0
votes
0answers
9 views

R package prcomp: does the output for res.ind$coord = predict(df.pca, newdata =novel_data)

I made a PCA plot with samples called data. I got the results for the individual samples using res.ind <- get_pca_ind(df.pca),...
0
votes
0answers
3 views

test proportional odds assumption of lagged variable in ordered logistic regression

I want to estimate transition probabilities between different disease states called "Remission", "Mild" and "moderate/severe". I have an unbalanced panel of 250 patients ...
0
votes
0answers
14 views

Compare models from different data subsets [duplicate]

I'm looking to compare linear regression models from different data subsets in r. The models are not nested. I have a model from the complete dataset with sex as a factor and then 2 separate models ...
0
votes
0answers
4 views

Estimating Sandwich Estimate and Confidence Interval from ipw weighted glmer

I wonder if anyone knows a package that can allow one to estimate the SE for an ipw weighted glmer (with Poisson and multinomial distribution)? I know that one can do it in SPSS but I have trouble ...
0
votes
0answers
14 views

R: Plot of the relationship between lambda values and coefficients in ridge regression

I'm using the code below to plot the relationship between the lambda values used of ridge regression and the coefficients: ...
0
votes
1answer
21 views

Normal distributon mean and standard deviation for group

My task is given below and I'm stuck on 3 step (probably I made a mistake in 2 step as I'm not 100% sure what m means there and what I have to calculate. My code is: ...
0
votes
0answers
12 views

ICC calculation for examiner and timepoint

How do I calculate an ICC for a dataset in which there are k examiners, and each examiner takes n measurements? I know that I can use the psych package in R to calculate the ICC across the k*n ...
0
votes
0answers
19 views

How to specify an interaction term with a lagged indep. variable and a year dummy with fixed effects regression?

I would like to compute the fixed effects model in the picture: Note that first and second term of the equation is district and year fixed effects. The Third term is the interaction between a ...
0
votes
0answers
15 views

Confusion about coefficients of logistic regression model produced by glm(family = binomial) in R

I have a response variable that is binary ( 1 - recovered, 0 - dead) and I will use two predictor variables as an example. One is continuous (age) and one is binary ( condition x: ( 1 - patient has it,...
0
votes
0answers
8 views

R: Interpreting optimal values of lambda for ridge regression the using both default and pre-defined results

I am trying to create a ridge regression model and I am currently estimating the optimal value for lambda. ...
0
votes
0answers
20 views

Comparing the marginal effect of a GLM to the OLS estimates

My question is, whether there is any way to (somewhat) compare the marginal effect of a GLM estimate to an OLS estimate. As in, "since the OLS and GLM results are very similar, I will favour OLS ...
0
votes
0answers
14 views

Comparing the marginal effects of glm output to polr output

I have a dependent variable that is technically ordinal, so I ran a ordered probit model (polr). However, an ordered probit model does not produce any residuals ...
0
votes
0answers
20 views

The interpretation of a positive glm coefficient, with a negative marginal effect

I found this post titled: "Positive coefficient but negative marginal effect in mlogit". EDIT: However I recently had the same "issue" with an ordinal probit model and the ...
1
vote
1answer
15 views

How to combine stability selection and model selection with LASSO?

I was reading about stability selection applied to LASSO. My understanding is that stability selection (Meinshausen & Buhlman, 2010) helps in finding stable variables, with error control provided ...
0
votes
0answers
12 views

How to set initial values for the prior model in a mix mode from DepmixS4 package in R

I am trying to figure out how to add a concomitant variable in the mix model in DepmixS4 package in R. My model looks like below ...
2
votes
1answer
26 views

Different Results for glmnet when standardize = FALSE

I asked this question at stackoverflow, but at this point I'm not exactly sure where it belongs because it is a question related to the standardization process of ...
0
votes
1answer
23 views

Showing the relationship between variables and drawing regression line

I am trying to solve a question which says: Use ggplot() to plot the graphs to see the relationship between variables GS with <...
0
votes
0answers
8 views

How to deal with missing value in longitudinal data using inverse probability weight

I have the following longitudinal data with time-varying variables: "exposure" is a categorical variable with three levels "event" is a binary variable with 0 means no event occurs,...
0
votes
0answers
9 views

Difference of plotting ellipse using R packages car and PlaneGeometry [closed]

I want to plot the ellipse $$ 4 x_{1}^{2}+3 x_{2}^{2}-2 \sqrt{2} x_{1} x_{2} =x^{\prime} A x = c^2 $$ where $c^{2}=1$, $x=(x_1,x_2)^\prime$ and $$A=\left[\begin{array}{rr}4 & -\sqrt{2} \\ -\sqrt{2}...
0
votes
0answers
10 views

What do i do with the error “there are aliased coefficients in the model” [duplicate]

I was trying to test for multicollinearity using VIF. Here is my codes: ...
0
votes
1answer
9 views

Differing P-Values on When Comparing lm() and pcor.test() for Partial Correlation

While reviewing partial correlation I ran across two methods for computation: use of bivariate linear regression (lm()) and partial correlation(pcor.test() from the ppcor library). I assumed the two ...
0
votes
0answers
7 views

How to call column names from an object in dplyr? [migrated]

I am trying to replace all zeros in multiple columns with NA using dplyr. However, since I have many variables, I do not want to call them all by one, but rather store them in an object that I can ...
0
votes
0answers
13 views

How to calculate the percentage deviance explained wiith glm.nb?

I’ve observed that when I fit a Negative Binomial regression with glm.nb, the null deviance I get from the model differs from the deviance of the null model. I think this is because both models ...
0
votes
0answers
8 views

Diagnostic analysis in mixed effects models using Half-Normal plot plot

I am intending to make the half-normal plot plot for a mixed effects model that was adjusted using the package lme4. To visualize the diagnostic analysis of this ...
0
votes
0answers
7 views

On the prediction with glmm with unknown random effect

I’m using glmm with logit link and a random intercept to take into account any differences between the years of sampling to model spatial species distribution. At this point, when I compare the ...
0
votes
0answers
3 views

Calculating Survey Weights For Stratified and Unequal Sampling

I have the responses from a survey which used stratification (12 strata) and unequal sampling (power allocation was used to determine the number of surveys to send to each stratum). The survey was ...
1
vote
1answer
23 views

How to create a threshold based for a classification model that determines if data falls within a range of data?

I have a data-set that is comparing two groups (Injury only (baseline) and Surgical Modification) across multiple injury severity values (Peak Force). Reference scatter plot for context: BBB score - ...
1
vote
0answers
24 views
+50

How flexible is Stata's ivpois? Could I use it for a (quasi) binomial distribution?

According to this post on statalist, Stata's ivpois (an instrumental variable approach) is pretty flexible, with very little assumptions. The problem mentioned in ...
0
votes
1answer
17 views

Including Fixed Effects in a LASSO/Elastic Net regression model (in R)

So this is a question has vaguely been asked before (see 1 and 2) but I have not been able to find a conclusive answer for anywhere. Essentially I have panel data for 300 US firms between 2012-2020 ...
1
vote
0answers
8 views

Is it possible to perform a meta-analysis on the SEE generated from models?

Let's say you were interested in performing a meta-analysis on the predictive validity of various simple linear regression models which differed in the method of extrapolation. One of the main metrics ...
0
votes
1answer
13 views

Continuous variable with very large OR and CI in my multiple logistic regression model

I'm trying to compute multiple logistic regression model and here are the results with covariates and covariates only: As you can see, I have a very large range of CI and OR. I don't really ...
2
votes
2answers
111 views

Probability distribution of a random variable

The table below shows the number of ice creams brought and the number of customers brought that number of ice creams. ...
0
votes
1answer
16 views

Why 95%CI of OR in tbl_regression does not match p-value (and is different from 95%CI from logistic.display)?

I performed multivariate logistic regression with this dataset: https://justpaste.it/61vgo ...
1
vote
2answers
71 views

Circular statistics polar coordinates data in R

I am very much new to dealing with this type of data (polar coordinates!) and it would be great if someone could help me out. My data come from an experiment in which I had 66 different pairs of ...
1
vote
0answers
33 views
+50

How to do a Control Function (CF) / Two Stage Residual Inclusion (2SRI) with an ordinal dependent variable in the first stage and a glm in the second

I am trying to use a Control Function (CF) / Two Stage Residual Inclusion (2SRI) approach, because the modeled relationship that I am trying to estimate is non-linear (my dependent variable has a ...
0
votes
0answers
28 views

Why is there discrepancies between population partial correlations from precision matrix estimates?

I am trying to make sense of how to interpret the precision matrix and why the precision matrix yields the partial correlations by building a model. I have tried the following code, but the results is ...
0
votes
0answers
3 views

What does the Random.(Intercept) summary output mean in mixor?

I am currently running an ordered logistic regression with random effects using the mixor package in R. However, I am not certain if I understand the summary results correctly. This is the smoking ...
0
votes
0answers
35 views

Model averaging a GLM function with equal weights

Background Let me first say that I read this post and that I looked at the BMS vignette. I used the package sure (CRAN, R ...

1
2 3 4 5
503