can anyone explain to me the tsSmooth function in R? [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 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)

Related

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.

r auto arima excluding (0,0,0) [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 6 years ago.
Improve this question
For the auto.arima function in forecast package of R, is there a way to let the function omit a model of arima(0,0,0), as I simply assume there must be some correlation within the dataset.
You could try looking at the help for the function
auto.arima(). Check the arguments start.p, start.q,
d,max.d

passing a data frame to a function in R language [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 want to pass a data frame to a function as an argument. And then inside the function, I want to work on different combinations of columns for graphical presentation. Basically, I want to do graphical presentation on different data files. I want that, I pass the data file as an argument and then get the graphs. How can I do this in R.
You are not giving us much info but here is a very basic starting point:
library(ggplot2) # if you don't have this library run install.packages('ggplot2')
myAmazingFunction <- function(myDF) {
ggplot(myDF,aes(X,Y))+geom_line()
}
df <-data.frame(X=1:30, Y=runif(30), Z=1.3*runif(30))
myAmazingFunction(df)

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)

logistic regression R prediction function [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 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.

Resources