# Why mathematica is returning error when computing correlation under Compile?

Can someone tell me what am I doing wrong here ..

``corr = Compile[{{array1, _Real, 1}, {array2, _Real, 1}},    Block[{corr}, corr = Correlation[array1, array2]; corr],CompilationTarget :> "C"] lm = Compile[{{array1, _Real, 1}, {array2, _Real, 1}},    Block[{mdlfit, x},  mdlfit = LinearModelFit[Join[Transpose[{array1}], Transpose[{array2}], 2], x, x];  {mdlfit, Sqrt[mdlfit["RSquared"]]}],CompilationTarget :> "C"] array1 = N[{2, 4, 5, 6, 3, 7, 5, 8, 9, 6, 4, 7, 6, 5}]; array2 = N[{5, 7, 8, 6, 3, 1, 2, 4, 5, 8, 7, 2, 3, 4}]; corr[array1, array2] // AbsoluteTiming lm[array1, array2] // AbsoluteTiming  ``

Output

``CompiledFunction::cfte: Compiled expression -0.218004439363 should be a rank 1 tensor of machine-size real numbers. >>  CompiledFunction::cfexe: Could not complete external evaluation; proceeding with uncompiled evaluation. >>  {0.049968, -0.218004439363}  {0.001135, {FittedModel[6.09022556391 -0.263157894737 x], 0.218004439363}}  ``

why computation of Correlation is giving error while LinearModelFit is working? If I get rid of ‘CompilationTarget’ from LinearModelFit then it’s also giving error

``CompiledFunction::cfex: Could not complete external evaluation at instruction 6; proceeding with uncompiled evaluation. >>  $$```$$ ``