Machine learning in trading: theory, models, practice and algo-trading - page 143

 
Vladimir Perervenko:

I had a discussion with Renat on a neighboring thread about the fate of the R language in MKL4/5. The solution and direction of development of MKL is now clear.

Good luck

If a person wants to write 100 - 1000 lines of code, which has already been written a long time ago, that's his right, while I'd rather do the same thing with one line in R

By the way, it's possible to make a challenge, to make a non-trivial task with some statistical methods and following learning and validating some model, and realize it in R and mql5+alglib and just compare code size...

 
Vladimir Perervenko:

I had a discussion with Renat on a neighboring thread about the fate of the R language in MKL4/5. The solution and direction of development of MKL is now clear.

Good luck

For those who haven't read that thread - direct interface from mql to R is not expected now. But there will be access to Alglib library ported to mql, so in mql code itself you can build trees or neuronc, optimize something with genetics, look for parameters for functions minimum/maximum. All possibilities -http://www.alglib.net

 
Vladimir Perervenko:

I had a discussion with Renat on a neighboring thread about the fate of the R language in MKL4/5. The solution and direction of development of MKL is now clear.

Good luck



I understand the trend. It is possible to make MT4 friendly with R. And MT4 is still very common right now. If you catch a good dependence in P, you may easily teach the model in the library for MT5 with the same parameters.

 

I have a matrix `"P"` with observations (line by line), for each row I count the distribution through `hist()`


breaks - put 50


A <- hist(P[n,],breaks = 50,plot = F)


but it turned out that on each line of the matrix `A$breaks` has a different length, despite the fact that the length of all lines in `P` is the same, how to make so that `A$breaks` are always the same size

 

If you feed one number into breaks, the result will be close to it, but not necessarily.

For exact match it is better to calculate minimal and maximal values beforehand, and to feed the parameter with your vector
A <- hist(P[n,],breaks = c(10:60),plot = F)

 
Dr.Trader:

If you feed one number into breaks, the result will be close to it, but not necessarily.

For exact match, better calculate minimal and maximal values beforehand, and feed your vector into parameter
A <- hist(P[n,],breaks = with(10:60),plot = F)


I tried it, but for some reason it fails

> A <- hist(P[1,],breaks = с(10:60),plot = F)
Error in hist.default(P[1, ], breaks = с(10:60), plot = F) : 
  could not find function "с"
> A <- hist(P[1,],breaks = 10:60,plot = F)
Error in hist.default(P[1, ], breaks = 10:60, plot = F) : 
  some 'x' not counted; maybe 'breaks' do not span range of 'x'
 

About the first error - I seem to have entered the Russian c instead of the English c :) Corrected my post above now.

Second error - P[1,] contains values either less than 10 or more than 60. You need to choose breaks in such a way as to include all values from P[1,]

 
Dr.Trader:

About the first error - I seem to have entered the Russian c instead of the English c :) Corrected my post above now.

Second error - P[1,] contains values either less than 10 or more than 60. You need to choose breaks in such a way as to include all values from P[1,]


I don't understand it(

here is a simple example

rn <- rnorm(100)
H <- hist(rn, breaks = 50, plot = F)
length(H$breaks)

Here's what and how should I do, so thatlength(H$breaks) would always be 50 ?

 

First we need to determine the minimum number in rn. Suppose -4. Then the maximal possible number: +4

The easiest way to call the function is to make the histogram go from -4 to +4:
H <- hist(rn, breaks = c(-4:4))

Example with error:
H <- hist(rn, breaks = c
(-1:1))
breaks is limited from -1 to 1, so if rnorm() produces a number less than -1 or more than +1, then hist() will produce an error.

Next, you need to create a vector with numbers from -4 to +4, so that the total length of the vector is 50. This is done with the seq() function:
seq(-4, 4, length.out=50)

That's all, you need to use the result of seq() in the histogram
H <- hist(rn, breaks = seq(-4, 4, length.out=50))

 
Dr.Trader:

First we need to determine the minimum number in rn. Suppose -4. Then the maximal possible number: +4

The easiest way to call the function is to make the histogram go from -4 to +4:
H <- hist(rn, breaks = c(-4:4))

Example with error:
H <- hist(rn, breaks = c
(-1:1))
breaks is limited from -1 to 1, so if rnorm() produces number less than -1 or more than +1, then hist() will produce error.

Next, you need to create a vector with numbers from -4 to +4, so that the total length of the vector is equal to 50. This is done with the seq() function:
seq(-4, 4, length.out=50)

That's all, you need to use the result of seq() in the histogram
H <- hist(rn, breaks = seq(-4, 4, length.out=50))

Thanks a lot, I'm not a clue about this econometrics stuff,

I think I got it.

rn <- rnorm(100)
Max <- max(rn)
Min <- min(rn)
range.vector <- seq(Min, Max, length.out=50)
H <- hist(rn, breaks = range.vector)
length(H$breaks)

[1] 50

Reason: