logistic regression R prediction function [closed] - r

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a glm model and use the following script:
prob=predict(myglm,type=("response"))
If i export this prob vector i get 1 column with all the probabilities.
prob=predict(myglm,type=("terms"))
This will provide me the terms for each observation in my data set.
My question is how can I export the data set with the
response probability column added to the end of the file?
Thanks is advance!

Is all you want to add a column with the predicted probability to the dataframe used to build the model? If so you do it this way:
mydata$prob <- predict(myglm, type = "response")
Please read An Introduction to R to learn the basics of the R language, it is the standard tutorial.

Related

can anyone explain to me the tsSmooth function in R? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
can anyone explain to me the tsSmooth function in R?
I would like to use it to obtain a univariate time series with a linear trend
Please note that on your code:
x<-rt(n=30,df=3, ncp=10)
y<-rt(n=20,df=3,ncp=20)
myseries<-c(x,y)
tsSmooth<-c(x,y)
newseries<-tsSmooth
you didn't apply the tsSmooth() function to your data. You simply created a vector named tsSmooth and another vector named newseries
tsSmooth() function uses a specific data input and doesn't provide much explanation.
There is this discussion that might help https://stats.stackexchange.com/questions/125946/generate-a-time-series-comprising-seasonal-trend-and-remainder-components-in-r
In addition, you could generate a simple trend using moving average. But I am not sure if it has all the statistical features you are looking for.
library("TTR")
plot.ts(myseries)
trendSMA <- SMA(myseries)
plot.ts(trendSMA)

Creating scatterplot using R [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I have imported a pimadata.csv to R, I have to create a scatter plot matrix for the first 8 columns in the pimadata; also have to find two variables that seem to have positive correlations. I used this line of code to create the plot;
pairs(pimadata[,1:8])
What should I do to show the correction between the variables?
You could use cor()
cor(pimadata[,1:8])
Since you did not provide the contents of pimadata.csv, I use the iris dataset as an example here.
head(iris)
pairs(iris[,1:4])
scatter plot
cors <- cor(iris[,1:4])
correction output

Calculating AWE from mclust package [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
Is it possible to calculate the Approximate Weight of Evidence (AWE) from information obtained via the mclust R package?
According to R documentation, you should have access to function awe(tree, data) since version R1.1.7.
From the example on the linked page (in case of broken link),
data(iris)
iris.m _ iris[,1:4]
awe.val <- awe(mhtree(iris.m), iris.m)
plot(awe.val)
Following the formula from Banfield, J. and Raftery, A. (1993) Model-based Gaussian and non-Gaussian clustering. Biometrics, 49, 803-821. -2*model$loglik + model$d*(log(model$n)+1.5) Where model represents the model with number of cluster solutions selected. Keeping this question in the hope that it may help someone in the future.

How do I normalize and denormalize data in R? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have data that contains 14 columns of predictors and 1 column of solution variable(y).
I wanted to know if there are any inbuilt functions to normalize and denormalize data in R.
Thank you.
normDataWithin of package {Rmisc} can be used: http://www.inside-r.org/packages/cran/Rmisc/docs/normDataWithin
Else following methods can be used:
(variable-mean)/sd . Following code can be used for a data.frame:
mydata$myNormalizedVar<-(mydata$myvar-mean(mydata$myvar))/sd(myvar)
log (log10), log2, and square root (sqrt)
Normal quantile normalization or normal quantile transformation. Try:
quantNorm = function(x){qnorm(rank(x,ties.method = "average")/(length(x)+1))}
hist(quantNorm(1:10000),100)

modelling claim loss using tweedie distribution in R [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
i want to fit a tweedie compound Poisson Gamma to my loss data using ptweedie.series R command. I am getting problems how to start with my fitting in R. Thanks in advance.
Performing such a fit is illustrated here:
library(tweedie)
example("tweedie-package")

Resources