How to simulate a stochastic process with drift? Can anyone explain? Aug 30, 2019 219 views

## 1 answer to this question.

Check out below code. It's an example to simulate random walk with drift.

```library(dplyr)
library(ggplot2)
rerun(5, rnorm(100)) %>%
set_names(paste0("sim", 1:5)) %>%
map(~ accumulate(., ~ .05 + .x + .y)) %>%
map_dfr(~ tibble(value = .x, step = 1:100), .id = "simulation") %>%
ggplot(aes(x = step, y = value)) +
geom_line(aes(color = simulation)) +
ggtitle("Simulations of a random walk with drift")```

In the above code, rerun creates sample data 5 times .map_dfr() return data frames created by row-binding and column-binding respectively. accumulate returns data point values from random values. answered Aug 30, 2019 by anonymous
• 33,010 points

+1 vote

## Custom Function to replace missing values in a vector with the mean of values

Try this. lapply(a,function(x){ifelse(is.na(x),mean(a,na.rm = TRUE ...READ MORE

## With the help of tidyverse: how to rename a column to a variable name

With the help of Dplyr: rename function ...READ MORE

+1 vote

## How to convert a list of vectors with various length into a Data.Frame?

We can easily use this command as.data.frame(lapply(d1, "length< ...READ MORE

## How to write a custom function which will replace all the missing values in a vector with the mean of values in R?

Consider this vector: a<-c(1,2,3,NA,4,5,NA,NA) Write the function to impute ...READ MORE

## What is a Random Walk model and how can you simulate it using R?

A random walk is a simple example ...READ MORE

## Random Walk model in R

A random walk is a simple example ...READ MORE

## Big Data transformations with R

Dear Koushik, Hope you are doing great. You can ...READ MORE

+1 vote