Displaying 20 results from an estimated 900 matches similar to: "Generating random normal distribution with mean 0 and standard deviation 1"
2005 Apr 20
2
fSeries Technical Analysis rsiTA problem
fSeries Technical Analysis rsiTA problem
Hello,
I?m trying to use the rsiTA() function but keep getting this error:
>rsiTA(tsx,14)
Error in "[.timeSeries"(close, 1:(length(close) - 1)) :
only 0's may be mixed with negative subscripts
Here?s is the first three lines of my data:
>tsx[1:3,]
close
2004-04-18 20:00:00 8702.82
2004-04-19
2006 Jun 19
2
saving rounded numbers as a new variable in a dataframe
A basic question, but one that eludes me. I have created a new variable
$numurder, which I have rounded off. I want to save the rounded off version
of this variable to an existing datafile called 'ngri.csv' .
numurder <-c((murder*no.of.cases)/100)
[[1]]
[1] 48.952 112.073 182.160 974.610 122.140 663.432 150.856 18.988
137.925 198.045 68.930 203.148 30.056 100.955
2006 Jul 27
2
Vector extracted from a matrix. How can I specify dimensions in as.matrix?
Transpose vector extracted from a matrix
Hello,
I am doing a recursive analysis that uses every line (vector) of a matrix in
a loop. In the model, I need to transpose those vectors that are extracted
from a matrix.
Using simple vectors (no matrix involved) the transpose function works fine:
simplevector <-matrix(1:3,3,1)
tsimplevector <-t(simplevector) #transposed
dim(simplevector)
2005 May 11
1
PDF Arial, Helvetica and Pagemaker 7.0
Hello,
I can generate PDF documents and they look good on acrobat reader. However,
when I import the PDFs in Pagemaker 7.0 (on windows2K), I get an error
message saying it does not recognize the Helvetica font.
I got this from ?pdf:
family
the font family to be used, one of "AvantGarde", "Bookman", "Courier",
"Helvetica", "Helvetica-Narrow",
2006 Oct 20
1
Cardinality constraint
Hello,
How do I implement a cardinality constraint with constrOptim?
I want to minimize (least square) a%*%x = 4
subject to
x1<2
x2<1
x3<4
count(x1, x2, x3)= 2 (cardinality constraint)
Is there a way to specify binary integer variables with constrOptim?
Here's my code so far:
a <-matrix(1:3,1,3)
fr <- function(x) {
(a%*%x-4)^2
}
2005 Apr 19
1
timeSeries Date Warning messages: Set timezone to GMT!
Hello, I must be doing something wrong that's very obvious. But I just
don't see it.
I changed my Windows Time Zone to GMT and my Financial Center to Montreal.
But I still get several warnings.
>Sys.timezone()
[1] "GMT Daylight Time"
>myFinCenter
[1] "Montreal"
>Sys.timeDate()
[1] "Montreal"
[1] [2005-04-19 10:55:02]
Warning messages:
1: Set
2006 Jun 21
4
help on ploting various lines
Dear All,
I tried to plot a variety of lines(curves) on same figure. What I did is,
plot(x=x1,y=y1)
lines(x=x2,y=y2)
lines(x=x3,y=y3)
...
In my data, the maximum of y1 is much smaller than those maximums of other y vectors. So, in the figure I got, there are some curves which are not complete, I mean, they were cut off at the maximum of y1 at the y axis. Could anybody point out some right
2005 Jun 01
1
Problem with fPortfolio
Hello,
I hesitate to call this a bug, because I could have forgotten something
important, but the MarkowitzPortfolio example in fPortfolio does not work
for me. Here's my code:
> library(fPortfolio)
>
>xmpPortfolio("\nStart: Load monthly data set of returns > ")
> data(berndtInvest)
> # Exclude Date, Market and Interest Rate columns from data
2012 Sep 18
4
add reference lines (or grid) in background
Dear all,
Is there a simple way to add reference lines in background? I am trying with
abline() or grid() but the lines, since they are executed after the plot
function, are draw on top. How can I draw such lines beneath the main plot?
Here is an example:
x<-rnorm(100)
boxplot(x)
abline(h=c(-1,0,1))
grid(NA, 4, lwd = 2)
regards,
Luigi Marongiu, MSc
[[alternative HTML
2016 Apr 27
3
Create a new variable and concatenation inside a "for" loop
Hello,
Suppose the you need a loop to create a new variable , i.e., you are not reading data from outside the loop. This is a simple example in Matlab code,
for i=1:5
r1=randn
r2=randn
r=[r1 r2]
c(i,:)=r; % creation of each row of c , % the ":" symbol indicates all columns. In R this would be [i,]
end
The output of interest is c which I'm creating inside the "for" loop
2016 Apr 27
0
Create a new variable and concatenation inside a "for" loop
"c" an extremely commonly-used function. Functions are first-class objects that occupy the same namespaces that variables do, so they can obscure each other. In short, don't use variables called "c" (R is case sensitive, so "C" has no such problem).
Wherever possible, avoid incremental concatenation like the plague. If you feel you must use it, at least
2016 Apr 27
3
Create a new variable and concatenation inside a "for" loop
...
"(R is case sensitive, so "C" has no such problem)."
Well, not quite. Try ?C
To add to the previous comments, Dr. Gordon appears to need to do
her/his homework and spend some time with an R tutorial or two before
posting further here. There are many good ones on the web. Some
recommendations can be found here:
https://www.rstudio.com/online-learning/#R
Cheers,
Bert
2016 Apr 28
0
Create a new variable and concatenation inside a "for" loop
Maybe I wasn't clear about my query.
I'm very familiar with pre-allocation and vectorization and I had already wrote an R code for this problem in this way. My question wasn't about the most efficient way to solve the problem. It was about whether in R it was possible to use the same index used in the loop to create a new variable and store the results in as in the example showed
2008 Apr 01
1
garch prediction
Hello
I want to predict the future values of time series with Garch
When I specified my model like this:
library(fGarch)
ret <- diff(log(x))*100
fit = garchFit(~arma(1,0,0)+garch(1, 1), data =ret)
predict(fit, n.ahead = 10)
meanForecast meanError standardDeviation
1 0.01371299 0.03086350 0.03305819
2 0.01211893 0.03094519 0.03350248
2008 Dec 09
1
Data Analysis Functions in R
Hi experts of R,
Are there any functions in R to test a univariate series for long memory
effects, structural breaks and time reversability?
I've found for ARCH effects(ArchTest), for normal (Shapiro.test,
KS.test(comparing with randn) and lillie.test) but not for the above
mentioned.
Where can I find a comprehensive list of functions available by type?
Thank you
Renato Costa
--
View this
2007 Nov 21
1
equivalent of Matlab robustfit?
Hi,
I've been using the Matlab robustfit function for linear regressions
where I suspect some data points are outliers. Is there an equivalent
function in R?
Take care, Darren
PS, This is the Matlab help on robustfit:
>> help robustfit
ROBUSTFIT Robust linear regression
B = ROBUSTFIT(X,Y) returns the vector B of regression coefficients,
obtained by performing robust
2003 Nov 03
2
problem building MS-Windows package under linux
hi there,
trying to follow the steps of Yan & Rossini 2003, I have two problems
:
first when I 'make CrossCompileBuild', I get :
******************************************************************************
make[1]: Entering directory `/home/ros/RWORK/CROSSSOMP/WinR/R-1.8.0/src/gnuwin32'
make -f Makefile.docfiles
make[2]: Entering directory
2013 Mar 21
2
NADA
Dear Users
Regarding the NADA package, would anyone be able to help me understand what
values are actually plotted on the Y axis of the plot obtained by using the
*ros* function on the data and plotting the result with the plot()
function? The Y axis is labeled "Values". According to the NADA user
manual, ros performs a log transformation of the data by default, but the
user can specify
2023 Jan 12
1
Reg: ggplot error
Hallo
I am not familiar with any of packages you use (except of MASS and ggplot2) and the code is too complicated without any hint where the error could come from and what is the message you get. I wonder if anybody would like to go through your whole code.
1. data seems to be read correctly
ICUData <- read.csv(file = "ICUData.csv", stringsAsFactors = TRUE)
ICUData.neuro <-
2012 Apr 15
2
xyplot type="l"
Probably a stupidly simple question, but I wouldn't know how to google it:
xyplot(neuro ~ time | UserID, data=data_sub)
creates a proper plot.
However, if I add
type = "l"
the lines do not go first through time1, then time2, then time3 etc but in
about 50% of all subjects the lines go through points seemingly random
(e.g. from 1 to 4 to 2 to 5 to 3).
The lines always start at time