Search results

  1. M

    Split Vector and apply Mann Kendall test

    I have a long vector of financial time series information, price and volume. I expand the price vector based on the volume vector so I essentially get a price per share traded, and so only one vector is analyzed. I would like to split this vector into lengths of 17500 each, and apply the...
  2. M

    Conditional Probability

    I am trying to create a matrix of the conditional probabilities from this: Signal <- runif(100) PercChange <- abs((rnorm(100)/100)) signalt <- seq(0, 1, 0.05) abst <- seq(0, c(0.02:1), 0.0025) CondDistMat <- matrix(0, nrow = length(signalt), ncol = length(abst)) for(j in...
  3. M

    Optimization of While and For loops

    Hi I am relatively new to R and have been using an algorithm for a project. I is in this case about 400 million. It is taking a rather long time to run ~20 - 30 minutes, and I was curious if there was a better way of running this? dPNProbExpand is a vector of probabilities, 1 row...
  4. M

    Aggregated data conditional on date

    Hi I have some data, where I aggregate the information on a unique minute basis with the below code based on a dataset for 1 day. I would however like to be able to run this code with a datafile that is combined of multiple days. I have a date column in the dataset, so I can use that as a...
  5. M

    Export certain datasets as csv from macro

    Hi I have a functioning macro that creates a list of datasets from a master file that is unique for each day. The datasets I create in the SAS macro therefore have the data added to them so they are easy to categorize. I would like to export some of the datasets as I create during the...
  6. M

    Aggregate data in 1 minute bars

    Hi I have been looking at many ways of aggregating data, but none seem to fit on the dataset I have. See below. What I would like to do is aggregate the data based on 1 minute time bars. The time variable is seconds after midnight, so 1:3599.999 second intervals, with the total amount of...
  7. M

    Create unique variable names in macro

    Hi I have a functioning macro running through daily datasets. The macro itself works as it should and I get the outputs I want. I would however like for SAS to save the files it generates as OUTPUTAdate OUTPUTBdate etc. I can do so using this: data&year&mon2&day2 and then substitute...
  8. M

    Expand Observations in New Column Based on Two Columns

    Hi I have read a csv file using the read.table function into R. It contains a list of variables which are numeric in class. I would like to create a new column based on two columns. Se example below, where C is my desired output. A B C 1 4 4 2 3 3 3 4 3 2 5 4 - - 4 - - 4 - -...
  9. M

    Create loop for Monte Carlo Simulation

    Hi I have some trouble writing out a monte carlo simulation properly. I assign variables for the process before the steps. The first step is assigning variable j = j + 1 Second step i draw three random numbers from a U(0,1) dist. u1, u2 and u3. Third step is a long if formula. It...
  10. M

    Add price information based on reference number to different observation

    Hi I have a large dataset that includes some observatios that are identified as either E or A. Observation A and E have a common reference ID number. Observation A incudes price information whereas E does not. However based on the reference number I would like to add the price information...